Open form to a specific item from continuous form

A

Annelie

I am double clicking an Employeename line in a continuousform from
TblEmployeetemp to open the data a single form with the employee detail to
examine why it won't update into the regular table. I have used this code
before but it was with the numeric value, not a text and I think that is the
problem. I get the following error message: Syntax error (comma) in a query
expression '[Employeename]=Doe, Jane MN'.
I can't figure out how to fix it.

The code is a such:
Private Sub txtEmployeeName_DblClick(Cancel As Integer)
On Error GoTo Err_txtEmployeeName_DblClick_Click
Dim DocName As String
stDocName = "FrmEmployeeListTemp"
Dim stLinkCriteria As String
stLinkCriteria = "[Employeename]=" & Me.txtemployeename

DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_txtEmployeeName_DblClick_Click:
Exit Sub

Err_txtEmployeeName_DblClick_Click:
MsgBox Err.Description
Resume Exit_txtEmployeeName_DblClick_Click
End Sub
 
T

tina

text values have to enclosed in single quotes. try

stLinkCriteria = "[Employeename]= '" & Me.txtemployeename & "'"

hth
 
A

Annelie

I am trying to understand the way this works, I added some extra spaces to
make the quotes more identifiable

Numeric field: stLinkCriteria = "[EmployeeID]=" & Me.txtEmployeeID
Text field: stLinkCriteria = "[Employeename]= (' " &
Me.txtemployeename & " ' ) "
I put brackets like for a spreadsheet function where I am assuming these
quotes apply, just to visualize?



tina said:
text values have to enclosed in single quotes. try

stLinkCriteria = "[Employeename]= '" & Me.txtemployeename & "'"

hth


Annelie said:
I am double clicking an Employeename line in a continuousform from
TblEmployeetemp to open the data a single form with the employee detail
to
examine why it won't update into the regular table. I have used this code
before but it was with the numeric value, not a text and I think that is the
problem. I get the following error message: Syntax error (comma) in a query
expression '[Employeename]=Doe, Jane MN'.
I can't figure out how to fix it.

The code is a such:
Private Sub txtEmployeeName_DblClick(Cancel As Integer)
On Error GoTo Err_txtEmployeeName_DblClick_Click
Dim DocName As String
stDocName = "FrmEmployeeListTemp"
Dim stLinkCriteria As String
stLinkCriteria = "[Employeename]=" & Me.txtemployeename

DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_txtEmployeeName_DblClick_Click:
Exit Sub

Err_txtEmployeeName_DblClick_Click:
MsgBox Err.Description
Resume Exit_txtEmployeeName_DblClick_Click
End Sub
 
T

tina

yes, you have the quotes correct, though without the extra spaces, of
course. and lose the parentheses, you don't need them.

hth


Annelie said:
I am trying to understand the way this works, I added some extra spaces to
make the quotes more identifiable

Numeric field: stLinkCriteria = "[EmployeeID]=" & Me.txtEmployeeID
Text field: stLinkCriteria = "[Employeename]= (' " &
Me.txtemployeename & " ' ) "
I put brackets like for a spreadsheet function where I am assuming these
quotes apply, just to visualize?



tina said:
text values have to enclosed in single quotes. try

stLinkCriteria = "[Employeename]= '" & Me.txtemployeename & "'"

hth


Annelie said:
I am double clicking an Employeename line in a continuousform from
TblEmployeetemp to open the data a single form with the employee detail
to
examine why it won't update into the regular table. I have used this code
before but it was with the numeric value, not a text and I think that
is
the
problem. I get the following error message: Syntax error (comma) in a query
expression '[Employeename]=Doe, Jane MN'.
I can't figure out how to fix it.

The code is a such:
Private Sub txtEmployeeName_DblClick(Cancel As Integer)
On Error GoTo Err_txtEmployeeName_DblClick_Click
Dim DocName As String
stDocName = "FrmEmployeeListTemp"
Dim stLinkCriteria As String
stLinkCriteria = "[Employeename]=" & Me.txtemployeename

DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_txtEmployeeName_DblClick_Click:
Exit Sub

Err_txtEmployeeName_DblClick_Click:
MsgBox Err.Description
Resume Exit_txtEmployeeName_DblClick_Click
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top