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

Coding Error.

Status
Not open for further replies.

jdwm2310

Technical User
Jul 26, 2001
396
US
Hi,

I inserted a preview button based on two forms. I want to view the person's reenrollment selection. Check this code out, I get an mismatch type error. Any suggestions.

On Error GoTo Err_Command36_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Enrollment (Below 170K)" And "SESP Enrollment (Above 170K)"

stLinkCriteria = "[EmpID]=" & Me![EmpID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_Command36_Click:
Exit Sub

Err_Command36_Click:
MsgBox Err.Description
Resume Exit_Command36_Click
 
Try enclosing the whole string in quotes:
Code:
stLinkCriteria = "[EmpID]= Me![EmpID]"
 
Hi!

One question, is EmpId a number? If it is defined as text then you will need to use this code:

stLinkCriteria = "[EmpID]='" & Me![EmpID] & "'"

It might be helpful in the debugging process to comment out the error handler, then access will let you break into the code and find where the error comes from. Alternatively you can set a break on one line and then step through the code one command at a time.

hth
Jeff Bridgham
 
dear jdwm2310,


this is the row where your error occurs:

AND is a logical operator which cannot connect 2 strings, but 2 boolean expressions

stDocName = "Enrollment (Below 170K)" And "SESP Enrollment (Above 170K)"

what to you want to do here??


HTH

regards Astrid
 
Astrid,

When an employee fills out one of these forms (Enrollment Below 170K) or (SESP Enrollment (Above 170K), the manager can preview their selection by clicking on this button. This button will preview the form whether its Form-Below 170K or Form-Above 170K. Do you understand what I want to do, I want to view the form that was completed by a particular employee. (And there are two forms)
Please let me know if you need more info.
 
dear jdwm2310,

you need to distinguish the chosen form's name before you can set the varibles value to it.

there must be somehow a property to find this out.

and then you could do it similar to this:

if formname = "Enrollment (Below 170K)" then
stDocName = "Enrollment (Below 170K)"
else
stDocName ="SESP Enrollment (Above 170K)"
end if

stLinkCriteria = "[EmpID]=" & Me![EmpID]
DoCmd.OpenForm stDocName, , , stLinkCriteria

HTH

regards Astrid
 
Sawatzky,

What do you mean 'you need to distinguish the chosen form's name before you can set the varibles value to it.

there must be somehow a property to find this out.'

The chosen form's name are as follow:
SESP Enrollment (Below 170K)
SESP Enrollment (Above 170K)




 
Sawatzky,

I get a run-time 3075
Syntax error in string in query expression '[Employee Information]='Ambrosini, Michael".



 
dear jdwm,

Syntax error in string in query expression '[Employee Information]='Ambrosini, Michael".

could be "[Employee Information] = 'Ambrosini, Michael' "

regards Astrid
 
dear jdwm,

with distinguish I meant:

You have to find out what form you want to open. There must be any condition for it. If you found the condition, you modify the if-statement I posted before.

regards astrid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top