what does this mean?

R

Roger

Set rst = CurrentDb.OpenRecordset("SELECT Birds.BirdCode FROM Birds " & _
"WHERE (((Birds.BirdCode)='" & Me("Bird" & i) & "'));")

What does that last few symbols mean? " ')); "
 
P

PC Datasheet

The whole expression is defining the recordset represented by Rst as a recordset
taken from the Birds table and the records are only those where the value of
BirdCode is equal to the value in the control, Birdi on the current form.
Apparently there are fields on the form that look like Bird1, Bird2, Bird3, etc
and somehow i is defined so that one of these specific fields is referred to.

In the symbols you refer to in your question moving right to left, the
semi-colon is the standard terminator for a SQL clause.The two open-left
parantheses close the two open-right parantheses immmediately following the word
Where. The value held in the field Birdi is text data type and therefore
Me("Bird" & i) must be enclosed in single quotes. The opening single quote
immediately follows the equal sign and the closing single quotes immediately
precedes the two open-left parantheses. The two double quotes in your question
enclose a string expression which is concatenated to complete the Where clause.
 
R

Roger

I'm getting a Type Mismatch error with this code. And reading from my VBA book, it means I've got a variable type mismatch. Can anyone help point out which part of the code has the Type Mismatch. And also decipher what this whole code means.
 
R

Randy Harris

Roger said:
I'm getting a Type Mismatch error with this code. And reading from my VBA
book, it means I've got a variable type mismatch. Can anyone help point out
which part of the code has the Type Mismatch. And also decipher what this
whole code means.


Take a look at the Birds table. See if BirdCode is actually a text field.
BirdCode sounds like it might be numeric.
 
V

Van T. Dinh

If you use A2K or A2K2 and you declared

Dim rst As Recordset

then it is likely that your variable "rst" has been defaulted to ADO
Recordset but you actually needed DAO Recordset.

Make sure you add the DAO Object Library 3.6 into the References of your
database. If you don't use ADO, remove ADO Object Library from the
References. Also, it is better to *always* disambiguate the object in the
Dim statements like:

Dim rst As DAO.Recordset

--
HTH
Van T. Dinh
MVP (Access)



Roger said:
I'm getting a Type Mismatch error with this code. And reading from my VBA
book, it means I've got a variable type mismatch. Can anyone help point out
which part of the code has the Type Mismatch. And also decipher what this
whole code means.
 
R

Roger

yes, BirdCode is a text fiel

From that code, only Birds.BirdCode and Bird can cause the Type Mismatch problem right
But I checked that both are string, I'm thinking there's a conflict with another code for something else
Do other events in other properties for control boxes affect each other?
 
R

Randy Harris

Roger said:
yes, BirdCode is a text field

From that code, only Birds.BirdCode and Bird can cause the Type Mismatch problem right?
But I checked that both are string, I'm thinking there's a conflict with
another code for something else.
Do other events in other properties for control boxes affect each other?

Roger, you've posted so little of the code that it is difficult to guess
what the problem might be. The way your snippet is written, Bird is not a
variable but rather a string literal. It looks as though the code might be
in an event for a form that has a control called Bird?? and i is supposed
to contain whatever the ?? is. Again, without seeing more of the code, it
is tough to guess.

Some suggestions:

Comment out the line that fails and add this line immediately above it.
MsgBox "Bird" & i
Run the code, if all is correct, what appears in the message box should be
the name of a control on your form.

Second suggestion - take a close look at the earlier reply from the very
learned Mr. Van T. Dinh.

Finally, if this doesn't help, post more of the code.

Best of Luck,
Randy
 

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

Top