J
jonathansnyder via AccessMonster.com
Hi folks,
I really stuck here, hoping you all can help.
I'm using a combo box to locate and display a record on a form. Code is as
follows:
Private Sub Combo48_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Tagger_ID] = '" & Me![Combo48] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Eval (Tagger_ID)
rs.Close
DoCmd.FindRecord Tagger_ID, , acEntire, , acSearchAll, , acCurrent
End Sub
If the record is edited, I would like to populate two fields within the table
indicating the date the record was updated, and the user name of the person
who updated it.
Code is a s follows:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim X As String
X = fOSUserName()
'nr is a global variable declared in module nr - sets nr equal to true if its
a new record
If nr = True Then
Exit Sub
End If
result = MsgBox("You are about to update the current record! Do you really
want to?", vbYesNo + vbCritical + vbDefaultButton2, "WARNING")
If result = vbNo Then
Me.Undo
Exit Sub
End If
Me.Update_Date = Date
Me.Update_Name = X
End Sub
If I edit the record and use the combo box to move to another record and
confirm that I want to update, the above code hangs up on the "me.update_date
= Date" line with the following error: "Update or cancelupdate without addnew
or edit". If I use the record selectors to move to another record after
editing and confirming, the code works fine and the update_date and user_name
fields are populated. I know this has something to do with the recordset
opened in the Private Sub Combo48_AfterUpdate() code above, but I cant seem
to figure out what to do to fix this.
Any and all help would be appreciated.
Thanks
Jonathan
I really stuck here, hoping you all can help.
I'm using a combo box to locate and display a record on a form. Code is as
follows:
Private Sub Combo48_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[Tagger_ID] = '" & Me![Combo48] & "'"
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
Eval (Tagger_ID)
rs.Close
DoCmd.FindRecord Tagger_ID, , acEntire, , acSearchAll, , acCurrent
End Sub
If the record is edited, I would like to populate two fields within the table
indicating the date the record was updated, and the user name of the person
who updated it.
Code is a s follows:
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim X As String
X = fOSUserName()
'nr is a global variable declared in module nr - sets nr equal to true if its
a new record
If nr = True Then
Exit Sub
End If
result = MsgBox("You are about to update the current record! Do you really
want to?", vbYesNo + vbCritical + vbDefaultButton2, "WARNING")
If result = vbNo Then
Me.Undo
Exit Sub
End If
Me.Update_Date = Date
Me.Update_Name = X
End Sub
If I edit the record and use the combo box to move to another record and
confirm that I want to update, the above code hangs up on the "me.update_date
= Date" line with the following error: "Update or cancelupdate without addnew
or edit". If I use the record selectors to move to another record after
editing and confirming, the code works fine and the update_date and user_name
fields are populated. I know this has something to do with the recordset
opened in the Private Sub Combo48_AfterUpdate() code above, but I cant seem
to figure out what to do to fix this.
Any and all help would be appreciated.
Thanks
Jonathan