A
Ayala
Hi,
I have to autonumber fields in two different tables, each
primary key field are called ProjectDataID and GenDataID.
the relationship between the two tables is one to many.
I have this code. And I need to get the GenDataID value
that access is assigning for then open the form with the
where condition set to this value (GenDataID = ??).
My code looks like this:
Private Sub cmdAddService_Click()
Dim strSQL As String
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open "Select * from tblGeneralData Where
GenDataID = 0"
.AddNew
!ProjectDataID = Me.ProjectDataID
.Update
End With ' until here the GenDataID is created and assigned
' to the proper ProjectDataID. Here is where I need to
'pick the value assigned to GenDataID to open the form.
'I try with no luck this:
'strSQL = "GenDataID Like " & rst.GenDataID
'or
'strSQL = "GenDataID Like " & rst(GenDataID)
'or
'strSQL = "GenDataID Like " & rst[GenDataID]
DoCmd.OpenForm "frmGeneralData", acNormal, , strSQL
rst.Close
End Sub
PLEASE I'VE BEEN TRYING TO SOLVE THIS FOR VERY LONG.
I NEED YOUR HELP.
THANK YOU.
I have to autonumber fields in two different tables, each
primary key field are called ProjectDataID and GenDataID.
the relationship between the two tables is one to many.
I have this code. And I need to get the GenDataID value
that access is assigning for then open the form with the
where condition set to this value (GenDataID = ??).
My code looks like this:
Private Sub cmdAddService_Click()
Dim strSQL As String
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
With rst
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenDynamic
.LockType = adLockOptimistic
.Open "Select * from tblGeneralData Where
GenDataID = 0"
.AddNew
!ProjectDataID = Me.ProjectDataID
.Update
End With ' until here the GenDataID is created and assigned
' to the proper ProjectDataID. Here is where I need to
'pick the value assigned to GenDataID to open the form.
'I try with no luck this:
'strSQL = "GenDataID Like " & rst.GenDataID
'or
'strSQL = "GenDataID Like " & rst(GenDataID)
'or
'strSQL = "GenDataID Like " & rst[GenDataID]
DoCmd.OpenForm "frmGeneralData", acNormal, , strSQL
rst.Close
End Sub
PLEASE I'VE BEEN TRYING TO SOLVE THIS FOR VERY LONG.
I NEED YOUR HELP.
THANK YOU.