Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

please help with this code 1

Status
Not open for further replies.

Travis33

Programmer
Nov 20, 2000
31
US
I HAVE THIS CODE BELOW THAT i AM TRYING TO HAVE MY FORM WHEN I ENTER IN NUMBERS INTO A COMBO BOX SCROLL THROUGH THE RECORDS THAT MATCH PART OR ALL OF THE STRING.

**********************************************************
Dim db As database, rst As Recordset, strsql As String
Set db = CurrentDb
Str = "select * from [mtusparts01 query]= " & Me.[partnumber] & " * "
Set rst = db.openrecordset(strsql)
If rst.RecordCount >= 1 Then
Me.RecordSource = strsql
Else
Exit Sub
End If
rst.Close
Set db = Nothing
***********************************************************

when I try to compile the code it gives me an error on
me.[partnumber]
it tells me "Argument Not Optional"
How do I fix this so my code will run
Thank You,
Travis
 
Hope this helps. Why don't you just use the autoexpand feature of the combobox? Then you don't need this code.
Otherwise, something looks like it's wrong with your SQL string. You don't have a "WHERE" clause.
You have:
Str = "select * from [mtusparts01 query]= " & Me.[partnumber] & " * "
Try
Str = "select * from [mtusparts01 query] where [mtusparts01 query].[partnumber] like " & Me.[partnumber] & " * "
Note: The "[partnumber]" part of this refers to whatever the respective field in your query is named, of course.
Also, "like" should be used instead of "=" when using wildcards.
Huge success to you!
 
Hope this helps. Why don't you just use the autoexpand feature of the combobox? Then you don't need this code.
Otherwise, something looks like it's wrong with your SQL string. You don't have a "WHERE" clause.
You have:
Str = "select * from [mtusparts01 query]= " & Me.[partnumber] & " * "
Try
Str = "select * from [mtusparts01 query] where [mtusparts01 query].[partnumber] like " & Me.[partnumber] & " * "
Note: The "[partnumber]" part of this refers to whatever the respective field in your query is named, of course.
Also, "like" should be used instead of "=" when using wildcards.
Huge success to you!
Mike Kemp
kempmike65@aol.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top