This is at least somewhat related to:
thread702-1553189
However, it's not exactly the same question, so I started a new thread.
I thought it would be something fairly simple. I want to select a specific record in the Form's recordset, and I have a specific reason for doing so.
One of the things I'm doing in the form with one particular button (same form as the other thread) is highlighting and "approving" - setting a checkbox field value to True/Yes or unchecking the same checkbox.
In that process, if there are enough records so that the form has to be scrolled to see them all, if the user were to scroll to the bottom, and "approve" a record, currently, the form's focus shoots to the top of the form.
Therefore, I wanted to add in a line of code (or however many lines required) to select the same record that was just approved.
To do so, I took a note from this thread:
And put a text box in the header, and am setting the value in that box to the ID field for the "approved" record, with the idea that I could then set the focus on or select that given record after the Form.Requery command. But no, for some reason, every thing I've tried causes that portion to error out.
Here's what I have so far:
If anyone looks at this, can follow it at all, and make a suggestion, I'm all ears.![[bigears] [bigears] [bigears]](/data/assets/smilies/bigears.gif)
--
"If to err is human, then I must be some kind of human!" -Me
thread702-1553189
However, it's not exactly the same question, so I started a new thread.
I thought it would be something fairly simple. I want to select a specific record in the Form's recordset, and I have a specific reason for doing so.
One of the things I'm doing in the form with one particular button (same form as the other thread) is highlighting and "approving" - setting a checkbox field value to True/Yes or unchecking the same checkbox.
In that process, if there are enough records so that the form has to be scrolled to see them all, if the user were to scroll to the bottom, and "approve" a record, currently, the form's focus shoots to the top of the form.
Therefore, I wanted to add in a line of code (or however many lines required) to select the same record that was just approved.
To do so, I took a note from this thread:
And put a text box in the header, and am setting the value in that box to the ID field for the "approved" record, with the idea that I could then set the focus on or select that given record after the Form.Requery command. But no, for some reason, every thing I've tried causes that portion to error out.
Here's what I have so far:
Code:
Private Sub cmdApprove_Click()
DoCmd.RunCommand acCmdSelectRecord
txtLast = Me.ImportID
If txtFileName = vbNullString Then Exit Sub
If Me.Approved = True Then
Me.Approved = False
Else
Me.Approved = True
End If
Form.Requery
'And below are the different methods I've tried - basically trying the same thing, but trying different options, none of which seem to work - at least for me in this instance.
'The line, "txtLast.SetFocus", is to set focus to the comparable text box first, b/c one of the error messages was telling me I couldn't refer to an object that doesn't have focus...
' txtLast.SetFocus
' DoCmd.RunCommand acCmdSelectRecord
' Forms!frmRandom!ImportID.SetFocus
'Forms!Files!FileID.SetFocus
' DoCmd.FindRecord txtLast, acAnywhere, , , , acAll
'DoCmd.FindRecord txtLast, acAnywhere, False, acSearchAll, , acAll, True
'DoCmd.FindRecord txtLast.Text, acAnywhere, , acSearchAll, , acCurrent
'DoCmd.FindRecord txtLast
End Sub
If anyone looks at this, can follow it at all, and make a suggestion, I'm all ears.
![[bigears] [bigears] [bigears]](/data/assets/smilies/bigears.gif)
--
"If to err is human, then I must be some kind of human!" -Me