Quick help with code

G

Guest

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.
 
A

Allen Browne

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
 
G

Guest

thanks.

Where would this line go?

Allen Browne said:
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

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

scubadiver said:
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.
 
A

Allen Browne

Place the IF line immediately after the Private Sub line.

Add an END IF line immeidate before the End Sub line.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

scubadiver said:
thanks.

Where would this line go?

Allen Browne said:
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

scubadiver said:
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.
 
G

Guest

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

Allen Browne said:
Place the IF line immediately after the Private Sub line.

Add an END IF line immeidate before the End Sub line.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

scubadiver said:
thanks.

Where would this line go?

Allen Browne said:
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


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.
 
A

Allen Browne

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

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

scubadiver said:
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

Allen Browne said:
Place the IF line immediately after the Private Sub line.

Add an END IF line immeidate before the End Sub line.

scubadiver said:
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


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.
 
G

Guest

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.


Allen Browne said:
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

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

scubadiver said:
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

Allen Browne said:
Place the IF line immediately after the Private Sub line.

Add an END IF line immeidate before the End Sub line.

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


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.
 
A

Allen Browne

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.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

scubadiver said:
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.


Allen Browne said:
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

scubadiver said:
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.

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.
 
G

Guest

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.



Allen Browne said:
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.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

scubadiver said:
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.


Allen Browne said:
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


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.

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.
 
A

Allen Browne

Good: you have found your problem.

The Value of the field/control is null.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

scubadiver said:
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.



Allen Browne said:
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.)

scubadiver said:
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


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.
 
G

Guest

Which means .....?

So it is a data problem rather than a design problem?


Allen Browne said:
Good: you have found your problem.

The Value of the field/control is null.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

scubadiver said:
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.



Allen Browne said:
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


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.
 
A

Allen Browne

Please go back and read the very first reply I gave you to your question.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

scubadiver said:
Which means .....?

So it is a data problem rather than a design problem?


Allen Browne said:
Good: you have found your problem.

The Value of the field/control is null.

scubadiver said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top