After "stop", it goes to
"If Not IsNull(Me.QueryNo) Then"
and then
"End If".
It bypasses the rest of the code. I have exactly the same code I posted
in
my first message in another database and it works fine.
:
Okay add this line to the top of your code:
Stop
When you run it, Access should stop there.
Press F8 to single-step through the code.
You will now have the job of testing the path it is taking, checking
the
variables, and tracing what's going on. (I can't do that for you.)
I enter a number in the text box, press the button and nothing
happens.
If
I
navigate through the records and try it goes back to the first
record.
There is no error message or number and the code compiles ok.
I tried adding your line but it doesn't seem to work.
:
When you say it "doesn't work", can you be more specific?
Error message? Error Number?
Does it compile when you choose Compile on the Debug menu?
Where have you declared rstClone?
Try adding this immediately after the Private Sub line:
Dim rstClone As DAO.Recordset
message
This is what I have done as you have suggested but it doesn't
work.
I
have
tried the code in an old version (that doesn't have the
If...Then)
and
it
works fine.
Private Sub ELSrch_Click()
If Not IsNull(Me.QueryNo) Then
Set rstClone = Me.RecordsetClone
rstClone.FindFirst "[QueryID] =" & Me.QueryNo
Me.Bookmark = rstClone.Bookmark
Set rstClone = Nothing
End If
End Sub
:
Place the IF line immediately after the Private Sub line.
Add an END IF line immeidate before the End Sub line.
message
thanks.
Where would this line go?
:
The error usually occurs if QueryNo is null, so the search
string
ends
up
as
juste:
[QueryID] =
which is invalid.
Try adding a check such as:
If Not IsNull(Me.QueryNo) Then
If QueryID is a Text field, (not a Number field), you need
extra
quotes
as
explained here:
http://allenbrowne.com/casu-17.html
message
Private Sub ELSrch_Click()
Set rstClone = Me.RecordsetClone
rstClone.FindFirst "[QueryID] =" & Me.QueryNo
Me.Bookmark = rstClone.Bookmark
Set rstClone = Nothing
Me.QueryNo = Null
End Sub
I have a syntax error in the second line (missing
operator).
"QueryID"
and
"QueryNo" are numbers.