Search For Record (1 Viewer)

David92595

Registered User.
Local time
Today, 13:28
Joined
Jun 28, 2011
Messages
44
Hello,

I'm in the (not) fun process of having to change the data type of our PK to accommodate new requirements set by our clients. So far the switch has been surprisingly painless, except for my current problem.
Basics: Running Access 2007 Front end, SQL 2008 R2 Backend.

I have an unbound text box with its Row Source set to a SQL statement that queries the necessary info, and it works beautifully. However, since we have switch data types of our PK from numeric to varchar the macro (below) no longer works.

Action Arguments
SearchForRecord ,,First,=[TS] =" & Str(Nz([Screen].[ActiveControl],0))

Any one know why and how I can fix this? This has brought my office to a near stand still!!!

Please Help Me!!!!

David92595
 

Addyman

Registered User.
Local time
Today, 13:28
Joined
Dec 29, 2011
Messages
90
With SQL, numeric values do not require a single quote wrapped around them but strings (e.g. varchar) do.

Try:

SearchForRecord ,,First,=[TS] ='" & Str(Nz([Screen].[ActiveControl],0)) & "'"
 

David92595

Registered User.
Local time
Today, 13:28
Joined
Jun 28, 2011
Messages
44
You forgot quotes before [TS], :D

Thank you for the explaination, you've helped me solve more than one problem today, of that I'm sure.

Thanks!

David92595
 

David92595

Registered User.
Local time
Today, 13:28
Joined
Jun 28, 2011
Messages
44
Follow up question:

Before I posted, I converted the macro I was using to a module, which is how I got the code I posted. Now that I've made the changes to the code, how to I call the function inside the module.

Module Name is: TS_Search

Public Function name is: TS_Search()

Does it matter if the sub where I'm calling the function from is public or private?

Thank you again!

David92595
 

Users who are viewing this thread

Top Bottom