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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with this piece of code

Status
Not open for further replies.

oop94

Programmer
Jun 14, 2005
31
US
For some reason it does not like the percent sign:

oSQL = "SELECT*"
FROM TableInfo
WHERE Caption Like "' & strTarget & "%'"

oResults = oSQL.Execute

Any ideas...
 
If you are using an Access database, use '*' rather than '%' for a wildcard.

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
Thanks traingamer. Do you have any idea by this code is giving me an error?

DoCmd.OpenReport(OperatingMechanism, [acViewPreview], , "[OperatingMechanism =]" & OperatingMechanism.Operating_Mechanism &,)
 
This is giving me one too:

DoCmd.OpenReport "OperatingMechanism", acViewPreview, , "[OperatingMechanism =]" & OperatingMechanism.Operating_Mechanism &

AAAAAAAAAAAAAAAAH
 
DoCmd.OpenReport "OperatingMechanism", acViewPreview, , "[OperatingMechanism] = " & OperatingMechanism.Operating_Mechanism
 
It could be a couple of things, but I suspect that
Code:
... "[OperatingMechanism[COLOR=blue] =][/color]" ...
should probably be
Code:
..."[OperatingMechanism[COLOR=blue]] = [/color]" ...

Greg
"Personally, I am always ready to learn, although I do not always like being taught." - Winston Churchill
 
For some reason this is still not printing only what it's shown on the screen. Should I do some kind of query definition? I was just wondering if I was missing something because OperatingMechanism is a table that is linked to the main table. So it is just printing all the records in the Operating Mechanism without taking into account the own it is displaying.

CODE:

Private Sub Print_OperatingMechanism_Click()
On Error GoTo Err_Print_OperatingMechanism_Click

'Dim stReportName As String

'stReportName = "OperatingMechanism"
DoCmd.OpenReport "OperatingMechanism", acViewPreview, , "[OperatingMechanism]=" & OperatingMechanism.Operating_Mechanism

Exit_Print_OperatingMechanism_Click:
Exit Sub

Err_Print_OperatingMechanism_Click:
MsgBox Err.Description
Resume Exit_Print_OperatingMechanism_Click
 
What does the "OperatingMechanism.Operating_Mechanism" refer to? Is this a field on a form? Try stepping through the code to see what value is represented by "OperatingMechanism.Operating_Mechanism" and verify that it's a legitimate value in your table.
 
DoCmd.OpenReport "OperatingMechanism", acViewPreview, , "[OperatingMechanism] = " & OperatingMechanism.Operating_Mechanism

Should work IF Operating_Mechanism is numeric.
If Operating_Mechanism is text, change it to...
Code:
DoCmd.OpenReport "OperatingMechanism", acViewPreview, , "[OperatingMechanism] = [b][COLOR=red]'[/color][/b]" & OperatingMechanism.Operating_Mechanism[b][COLOR=red] & "'"[/color][/b]

Randy
 
I think it is not even making it to the code because I added a STOP command and it never did :S
 
Are you getting any error messages? Can you step through the code to figure out where it's failing?
 
I am not getting any messages but I cannot step through (I bet I am missing something). It's the "InputScreen" form, and the macro is the printer next to the "Operating Mechanism" textbox.
 
I added a command and set the on click event to [EventProcedure] and for some reason it gives me an error message. Thus, I does not even make it to the code. Any ideas?
 
while communicating with the OLE server or ActiveX control:
- The expression may not result in the name of a macro, the name of a user-defined function, or [Event Procedure]
- There may have been an error evaluating the function, event, or macro.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top