S
Sash
I'm using the following code to read through a continuous form and update the
table InvLocation. It works if the user does not update the first record on
the continuous form. How can I set the bookmark to always be the first
record on the continuous form? Or maybe I'm totally using bookmark
incorrectly.
Dim rstForm As DAO.Recordset
Dim rstDestination As DAO.Recordset
Dim dbs As DAO.Database
Set dbs = CurrentDb
Set rstForm = Me.RecordsetClone
Set rstDestination = dbs.OpenRecordset("InvLocation")
'CHECK RECORD SOURCE FOR RECORDS
If Not rstForm.BOF And Not rstForm.EOF Then
rstForm.MoveFirst
GoTo UpInvQty
Else
MsgBox "No Inventory Items to Add"
Exit Sub
End If
UpInvQty:
Do Until rstForm.EOF
If rstForm!INV_QTY > 1 Then
Me.Bookmark = rstForm.Bookmark
'SET FORM RECORDSET TO MAIN RECORDSET
'ADD NEW RECORD
rstDestination.addnew
rstDestination!OFFID = rstForm!ID
rstDestination!ITEM_NO = rstForm!ITEM_NO
rstDestination!DESCR = rstForm!DESCR
rstDestination!UM = rstForm!UM
rstDestination!PRICE = rstForm!PRICE
rstDestination!MFR = rstForm!MFR
rstDestination!MFRCat = rstForm!MFRCat
rstDestination!CONTAINS = rstForm!CONTAINS
rstDestination!CHANGE_MFR = rstForm!CHANGE_MFR
rstDestination!Inv_LOCATION = rstForm!Inv_LOCATION
rstDestination!Status = rstForm!Status
rstDestination!DateCounted = rstForm!DateCounted
rstDestination!INV_QTY = rstForm!INV_QTY
rstDestination!CountedBy = rstForm!CountedBy
rstDestination![5orUnder] = rstForm![5orUnder]
'UPDATE RECORD
rstDestination.Update
End If
rstForm.MoveNext
Loop
DoCmd.Close
Dim frmAdded As String
frmAdded = "frmAdded"
DoCmd.OpenForm frmAdded
table InvLocation. It works if the user does not update the first record on
the continuous form. How can I set the bookmark to always be the first
record on the continuous form? Or maybe I'm totally using bookmark
incorrectly.
Dim rstForm As DAO.Recordset
Dim rstDestination As DAO.Recordset
Dim dbs As DAO.Database
Set dbs = CurrentDb
Set rstForm = Me.RecordsetClone
Set rstDestination = dbs.OpenRecordset("InvLocation")
'CHECK RECORD SOURCE FOR RECORDS
If Not rstForm.BOF And Not rstForm.EOF Then
rstForm.MoveFirst
GoTo UpInvQty
Else
MsgBox "No Inventory Items to Add"
Exit Sub
End If
UpInvQty:
Do Until rstForm.EOF
If rstForm!INV_QTY > 1 Then
Me.Bookmark = rstForm.Bookmark
'SET FORM RECORDSET TO MAIN RECORDSET
'ADD NEW RECORD
rstDestination.addnew
rstDestination!OFFID = rstForm!ID
rstDestination!ITEM_NO = rstForm!ITEM_NO
rstDestination!DESCR = rstForm!DESCR
rstDestination!UM = rstForm!UM
rstDestination!PRICE = rstForm!PRICE
rstDestination!MFR = rstForm!MFR
rstDestination!MFRCat = rstForm!MFRCat
rstDestination!CONTAINS = rstForm!CONTAINS
rstDestination!CHANGE_MFR = rstForm!CHANGE_MFR
rstDestination!Inv_LOCATION = rstForm!Inv_LOCATION
rstDestination!Status = rstForm!Status
rstDestination!DateCounted = rstForm!DateCounted
rstDestination!INV_QTY = rstForm!INV_QTY
rstDestination!CountedBy = rstForm!CountedBy
rstDestination![5orUnder] = rstForm![5orUnder]
'UPDATE RECORD
rstDestination.Update
End If
rstForm.MoveNext
Loop
DoCmd.Close
Dim frmAdded As String
frmAdded = "frmAdded"
DoCmd.OpenForm frmAdded