I have some code that works off the update event of a textbox field (which is a part of a record in a continuous form). If certain conditions are met (following the updating of the field), I want a warning message to flash up and then the cursor must flash in the textbox relating to that record.
So, if a user updates the field on the 1st record and then clicks on the 10th record (or anywhere), the warning message (if appropriate) must appear and then the cursor must move back to the 1st record textbox field.
I would have thought that this would be basic to do but apparently even the most outwardly simple things in Access VB are made 10 times more difficult by the lack of adequate documentation.
I have spent the best part of 2 days trying to do this and as I have not solved it, I can say I am no closer than when I started.
I have tried used Absolute position, DoCmd FindRecord and many attempts on bookmarking. Nothing seems to work.
If anyone has a solution to this it would be much appreciated.
The following code is part of the after update event of the textbox in question. It gives me a data type mismatch when I try and use the Findnext method (see below). Am I on the right track here?
~~~~
Public varID As Variant
'Declared in a module and holds the value of a unique field in the record in question.
~~~~
Dim strBookmark As String
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClo ne
If Not IsEmpty(varID) Then
strBookmark = "code_no = " & varID 'code_no is a unique identifier for the record.
Debug.Print strBookmark 'All works fine, debug output="code_no = 1001" which is correct.
With rst
.FindFirst strBookmark 'Problem is here! Data type mismatch error.
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
End If
End With
End If
So, if a user updates the field on the 1st record and then clicks on the 10th record (or anywhere), the warning message (if appropriate) must appear and then the cursor must move back to the 1st record textbox field.
I would have thought that this would be basic to do but apparently even the most outwardly simple things in Access VB are made 10 times more difficult by the lack of adequate documentation.
I have spent the best part of 2 days trying to do this and as I have not solved it, I can say I am no closer than when I started.
I have tried used Absolute position, DoCmd FindRecord and many attempts on bookmarking. Nothing seems to work.
If anyone has a solution to this it would be much appreciated.
The following code is part of the after update event of the textbox in question. It gives me a data type mismatch when I try and use the Findnext method (see below). Am I on the right track here?
~~~~
Public varID As Variant
'Declared in a module and holds the value of a unique field in the record in question.
~~~~
Dim strBookmark As String
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClo ne
If Not IsEmpty(varID) Then
strBookmark = "code_no = " & varID 'code_no is a unique identifier for the record.
Debug.Print strBookmark 'All works fine, debug output="code_no = 1001" which is correct.
With rst
.FindFirst strBookmark 'Problem is here! Data type mismatch error.
If Not rst.NoMatch Then
Me.Bookmark = rst.Bookmark
End If
End With
End If
Comment