Code Problems! AHhh!

lilmikey1982

Registered User.
Local time
Today, 18:02
Joined
Jun 26, 2002
Messages
14
I am having some issues with this code. It is meant to use 3 drop down menus, that search a database of pictures. And the first two work great. It's the 3rd one I have a problem with. It keeps asking me for a paramter on the end one. I am VERY not smart at VB, so any help you could offer, would be great. I will copy the part of the code that is giving me problems, and if anyone needs or wants to see the file, I can send it over e-mail or something. Thanks again!

---Start of Code---
Private Sub cboNumericField_AfterUpdate()

Dim strSQLSF As String

strSQLSF = " SELECT * FROM tblDemo "
strSQLSF = strSQLSF & " WHERE tblDemo.RowField = '" & cboRowField & "' And "
strSQLSF = strSQLSF & " tblDemo.ColumnField = '" & cboColumnField & "' And "
strSQLSF = strSQLSF & " tblDemo.NumericField = " & cboNumericField

Me!sfrmForm.LinkChildFields = ""
Me!sfrmForm.LinkMasterFields = ""

Me!sfrmForm.LinkChildFields = "RowField;ColumnField;NumericField"
Me!sfrmForm.LinkMasterFields = "RowField;ColumnField;NumericField"
Me.RecordSource = strSQLSF <b>(It's right here that is highlighted and giving me problems, I think!!)</b>
Me.Requery

End Sub
 
One of the field names is mis-spelled. Add a Debug.Print line so you can see the contents of strSQLSF in the immediate window.
 
OK. Now, no making fun of me, but I've never heard of a debug.print line. How do I put one of those in?

-Mike
 
After you've built your strSQLSF add this line of code:
Debug.Print strSQLSF
to have the value of strSQLSF displayed and checkable in the immediate window after the code is run.
 
Just wondering if there should be a Me. (or Me! ?)in front of the cboRowField etc..
 
A couple of ideas. First shouldn't the SQL end in a semicolon? Second does cboNumericField return a number or a string (that looks like a numbre)?

HTH
 
cbNumericField was originally going to return a number, but then I changed it to text. But I didn't change the field name to save time. This might be where I am having issues.
 
It's not the field name that is causing the problem it's that you have forgotten to put single quotes around it (like the other 2 cbofields) which is needed for text strings.

HTH
 
I'm still a little lost. I think it's because I haven't had my morning coffee. So it needs single quotes around the code?
 

Users who are viewing this thread

Back
Top Bottom