Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / April 2008

Tip: Looking for answers? Try searching our database.

Query question involving AutoNumber data type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MichaelJohnson168@hotmail.com - 16 Apr 2008 20:31 GMT
The primary key in the customers table is an AutoNumber field type. I
have a form which is to perform a search from a textbox named
CustomerSearch and is to be compared to the CustomerID in the table
until it finds the CustomerID or reaches the EOF.

The problem is that the textbox is sending the number as a string type
and the field is an Autonumber. Therefore I am getting the following
error message:

Syntax error (missing operator) in query expression '* Customers.
[CustomerID]'

Set dbsRDP = CurrentDb
strSQL = "SELECT * Customers.[CustomerID], Customers.[CustomerFName],
Customers.[CustomerMI], Customers.[CustomerLName],Customers.
[CustomerAddress], Customers.[CustomerCity], Customers.
[CustomerState], Customers.[CustomerZip], Customers.[CustomerPhone],
Customers.[CustomerEmail] " & _
"FROM Customers " & _
"WHERE Customers.[CustomerID]='" & Me.txtCustomerSearch.Value & " ';"

Set rstCustomers = dbsRDP.OpenRecordset(strSQL, dbOpenDynaset) <----
This is where the error message occurs

Can someone let me know how I can perform this search properly?

Thanks in advance.
akphidelt - 16 Apr 2008 20:53 GMT
You are creating a string type for the ID by doing '" &
Me.txtCustomerSearch.Value

Try doing

=" & Me.txtCustomerSearch.Value & ";"

A better way would be to tell vba it's an integer

Dim MyID as Integer

MyID = Me.txtCustomerSearch

Then the formula would be =" & MyID & ";"

> The primary key in the customers table is an AutoNumber field type. I
> have a form which is to perform a search from a textbox named
[quoted text clipped - 23 lines]
>
> Thanks in advance.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.