K
kcsims
I am having problems here and I know it's something simple and stupid that
I'm missing but here goes. I have a form that creates a new record into the
table "ASSET". The table "ASSET" has a one-to-many relationship with
"INTERVAL". I am able to add the record to "ASSET" no problem, but I need to
add a record into "INTERVAL". My "INTERVAL" table uses the ASSET_ID as a
foriegn key from "ASSET". The follow is my code:
Private Sub cmdSAVE_Click()
Dim MYDB As DATABASE
Dim rstINTERVAL As Recordset
Dim strASSET_NAME As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Set MYDB = OpenDatabase("test.mdb")
Set rstINTERVAL = MYDB.OpenRecordset("INTERVAL")
With rstINTERVAL
.AddNew
!ASSET_ID = Me.txtASSET_NAME
.Update
End With
MYDB.CLOSE
End Sub
I think the problem is the statement
!ASSET_ID = Me.txtASSET_NAME
I think I need to find the autonumber that was generated when I save the
record into the "ASSET" table. Please help me out. Thanks.
I'm missing but here goes. I have a form that creates a new record into the
table "ASSET". The table "ASSET" has a one-to-many relationship with
"INTERVAL". I am able to add the record to "ASSET" no problem, but I need to
add a record into "INTERVAL". My "INTERVAL" table uses the ASSET_ID as a
foriegn key from "ASSET". The follow is my code:
Private Sub cmdSAVE_Click()
Dim MYDB As DATABASE
Dim rstINTERVAL As Recordset
Dim strASSET_NAME As String
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Set MYDB = OpenDatabase("test.mdb")
Set rstINTERVAL = MYDB.OpenRecordset("INTERVAL")
With rstINTERVAL
.AddNew
!ASSET_ID = Me.txtASSET_NAME
.Update
End With
MYDB.CLOSE
End Sub
I think the problem is the statement
!ASSET_ID = Me.txtASSET_NAME
I think I need to find the autonumber that was generated when I save the
record into the "ASSET" table. Please help me out. Thanks.