J
Joe
Can anyone please help me?
The Debug.Print rsAN.Fields(0) always rerun 0
Can you please check what has to be changed?
Thanks
Joe
Option Compare Database
Option Explicit
Dim cnn As ADODB.Connection
Dim strSQL As String, strMsg As String, MAutoNum As String,
strOpenArgs As String
Dim lngNewFamilyID As Long
=================
Private Sub SaveMember(lngFamilyID)
Dim rs As ADODB.Recordset
Dim rsAN As ADODB.Recordset
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
Set rsAN = New ADODB.Recordset
rs.Open "TblClients", cnn, adOpenStatic, adLockOptimistic
If lngFamilyID = 0 Then
rs.AddNew
strSQL = "INSERT INTO tblTemp(UserID) " _
& "VALUES('" & CurrentUser & "')"
cnn.Execute strSQL
strSQL = "select @@Identity FROM tblTemp"
rsAN.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
Debug.Print rsAN.Fields(0)
Else
rs.Find "FamilyID = " & lngFamilyID
If rs.EOF Then
Beep
MsgBox "can't find this record"
GoTo Exit_SaveMember
End If
End If
==-=-=-===========================
I was told to create a tblTemp Table with one field UserID
And to use this statement
strSQL = "INSERT INTO tblTemp(UserID) " _
& "VALUES('" & CurrentUser & "')"
cnn.Execute strSQL
Being I don't understand how the @@Identity function works
I did what I was told.
Now, can you please tell me what has to be changed?
Or should I use my real table?
FYI I'm not using the secured.mdw file, only 1 MDB file.
Thanks
The Debug.Print rsAN.Fields(0) always rerun 0
Can you please check what has to be changed?
Thanks
Joe
Option Compare Database
Option Explicit
Dim cnn As ADODB.Connection
Dim strSQL As String, strMsg As String, MAutoNum As String,
strOpenArgs As String
Dim lngNewFamilyID As Long
=================
Private Sub SaveMember(lngFamilyID)
Dim rs As ADODB.Recordset
Dim rsAN As ADODB.Recordset
Set cnn = CurrentProject.Connection
Set rs = New ADODB.Recordset
Set rsAN = New ADODB.Recordset
rs.Open "TblClients", cnn, adOpenStatic, adLockOptimistic
If lngFamilyID = 0 Then
rs.AddNew
strSQL = "INSERT INTO tblTemp(UserID) " _
& "VALUES('" & CurrentUser & "')"
cnn.Execute strSQL
strSQL = "select @@Identity FROM tblTemp"
rsAN.Open strSQL, cnn, adOpenKeyset, adLockOptimistic
Debug.Print rsAN.Fields(0)
Else
rs.Find "FamilyID = " & lngFamilyID
If rs.EOF Then
Beep
MsgBox "can't find this record"
GoTo Exit_SaveMember
End If
End If
==-=-=-===========================
I was told to create a tblTemp Table with one field UserID
And to use this statement
strSQL = "INSERT INTO tblTemp(UserID) " _
& "VALUES('" & CurrentUser & "')"
cnn.Execute strSQL
Being I don't understand how the @@Identity function works
I did what I was told.
Now, can you please tell me what has to be changed?
Or should I use my real table?
FYI I'm not using the secured.mdw file, only 1 MDB file.
Thanks