Problem with subform popup

M

Michelle

I have a main from based on tblEquipment it has a subform based on tblIPData.
On the main form I put a command button that makes the subform popup however
it is not pulling the IDTag # into the subform.

tblEquipment
IDTag - Text Primay Key
Equipment Type
Location
LocationDesc
Manufacturer
Model
SerialNum
PONum
Contract(s)
WarrantyType
WarrantyExpDate
Surplus
SurplusDate

tblIPData
ID - AutoNum Primary Key
EIDTag
MAC
IP
SN
GW
PDNS
SDNS
Wireless

Relationship is tblEquipment IDTag = tblIPData EIDTag

Code for cmd button:
Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=" & Me![IDTag]
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmipdata!eidtag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

I get the following error....
Syntax error (missing operator0 in query expression '[EIDTag]=12KZ791'.
 
D

Douglas J. Steele

From the value in the error message, EIDTag is obviously a text field. That
means you need to put quotes around the value. Assuming that the value can
never has an apostrophe in it, try:

stLinkCriteria = "[EIDTag]='" & Me![IDTag] & "'"

Exagerated for clarity, that's

stLinkCriteria = "[EIDTag]= ' " & Me![IDTag] & " ' "

If it can have an apostrophe, try

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"

That's three double quotes in a row in front of & Me![IDTag], and four
double quotes in a row afterwards.
 
M

Michelle

That fixed my problem but now I am getting the following when the subform
opens.
#Name? In the EIDTag...here is my code.

Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmipdata!eidtag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Douglas J. Steele said:
From the value in the error message, EIDTag is obviously a text field. That
means you need to put quotes around the value. Assuming that the value can
never has an apostrophe in it, try:

stLinkCriteria = "[EIDTag]='" & Me![IDTag] & "'"

Exagerated for clarity, that's

stLinkCriteria = "[EIDTag]= ' " & Me![IDTag] & " ' "

If it can have an apostrophe, try

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"

That's three double quotes in a row in front of & Me![IDTag], and four
double quotes in a row afterwards.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michelle said:
I have a main from based on tblEquipment it has a subform based on
tblIPData.
On the main form I put a command button that makes the subform popup
however
it is not pulling the IDTag # into the subform.


I get the following error....
Syntax error (missing operator0 in query expression '[EIDTag]=12KZ791'.
 
D

Douglas J. Steele

If you simply open the form by itself (as opposed to using that code), do
you still get the #Name?

If so, the problem's with the form, not with the code that's opening it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michelle said:
That fixed my problem but now I am getting the following when the subform
opens.
#Name? In the EIDTag...here is my code.

Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmipdata!eidtag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Douglas J. Steele said:
From the value in the error message, EIDTag is obviously a text field.
That
means you need to put quotes around the value. Assuming that the value
can
never has an apostrophe in it, try:

stLinkCriteria = "[EIDTag]='" & Me![IDTag] & "'"

Exagerated for clarity, that's

stLinkCriteria = "[EIDTag]= ' " & Me![IDTag] & " ' "

If it can have an apostrophe, try

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"

That's three double quotes in a row in front of & Me![IDTag], and four
double quotes in a row afterwards.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michelle said:
I have a main from based on tblEquipment it has a subform based on
tblIPData.
On the main form I put a command button that makes the subform popup
however
it is not pulling the IDTag # into the subform.


I get the following error....
Syntax error (missing operator0 in query expression '[EIDTag]=12KZ791'.
 
M

Michelle

I did not get that when I just open the form...It seem to have went away and
is now replaced by Type mismatch error.

Douglas J. Steele said:
If you simply open the form by itself (as opposed to using that code), do
you still get the #Name?

If so, the problem's with the form, not with the code that's opening it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michelle said:
That fixed my problem but now I am getting the following when the subform
opens.
#Name? In the EIDTag...here is my code.

Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmipdata!eidtag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Douglas J. Steele said:
From the value in the error message, EIDTag is obviously a text field.
That
means you need to put quotes around the value. Assuming that the value
can
never has an apostrophe in it, try:

stLinkCriteria = "[EIDTag]='" & Me![IDTag] & "'"

Exagerated for clarity, that's

stLinkCriteria = "[EIDTag]= ' " & Me![IDTag] & " ' "

If it can have an apostrophe, try

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"

That's three double quotes in a row in front of & Me![IDTag], and four
double quotes in a row afterwards.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have a main from based on tblEquipment it has a subform based on
tblIPData.
On the main form I put a command button that makes the subform popup
however
it is not pulling the IDTag # into the subform.


I get the following error....
Syntax error (missing operator0 in query expression '[EIDTag]=12KZ791'.
 
M

Michelle

When I use the
stLinkCriteria = "[EIDTag]='" & Me![IDTag] & "'"
I get the $Name? Error
When I use the
stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
I get the type mismatch error.

Douglas J. Steele said:
If you simply open the form by itself (as opposed to using that code), do
you still get the #Name?

If so, the problem's with the form, not with the code that's opening it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michelle said:
That fixed my problem but now I am getting the following when the subform
opens.
#Name? In the EIDTag...here is my code.

Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmipdata!eidtag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

Douglas J. Steele said:
From the value in the error message, EIDTag is obviously a text field.
That
means you need to put quotes around the value. Assuming that the value
can
never has an apostrophe in it, try:

stLinkCriteria = "[EIDTag]='" & Me![IDTag] & "'"

Exagerated for clarity, that's

stLinkCriteria = "[EIDTag]= ' " & Me![IDTag] & " ' "

If it can have an apostrophe, try

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"

That's three double quotes in a row in front of & Me![IDTag], and four
double quotes in a row afterwards.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have a main from based on tblEquipment it has a subform based on
tblIPData.
On the main form I put a command button that makes the subform popup
however
it is not pulling the IDTag # into the subform.


I get the following error....
Syntax error (missing operator0 in query expression '[EIDTag]=12KZ791'.
 
D

Douglas J. Steele

Add a line of code Debug.Print stLinkCriteria to your routine as indicated
below:

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
Debug.Print strCriteria
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria

When the code runs (and fails), go to the Immediate Window (Ctrl-G), and see
what's typed there. Copy it and paste it into your reply.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michelle said:
When I use the
stLinkCriteria = "[EIDTag]='" & Me![IDTag] & "'"
I get the $Name? Error
When I use the
stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
I get the type mismatch error.

Douglas J. Steele said:
If you simply open the form by itself (as opposed to using that code), do
you still get the #Name?

If so, the problem's with the form, not with the code that's opening it.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Michelle said:
That fixed my problem but now I am getting the following when the
subform
opens.
#Name? In the EIDTag...here is my code.

Private Sub IPData_Click()
On Error GoTo Err_IPData_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "frmIPData"

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"
DoCmd.OpenForm stDocName, acFormDS, , stLinkCriteria
Forms!frmipdata!eidtag.DefaultValue = Me.IDTag
DoCmd.MoveSize 3 * 1440, 2 * 1440, 9.5 * 1440, 5 * 1440

Exit_IPData_Click:
Exit Sub

Err_IPData_Click:
MsgBox Err.Description
Resume Exit_IPData_Click
End Sub

:

From the value in the error message, EIDTag is obviously a text field.
That
means you need to put quotes around the value. Assuming that the value
can
never has an apostrophe in it, try:

stLinkCriteria = "[EIDTag]='" & Me![IDTag] & "'"

Exagerated for clarity, that's

stLinkCriteria = "[EIDTag]= ' " & Me![IDTag] & " ' "

If it can have an apostrophe, try

stLinkCriteria = "[EIDTag]=""" & Me![IDTag] & """"

That's three double quotes in a row in front of & Me![IDTag], and four
double quotes in a row afterwards.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


I have a main from based on tblEquipment it has a subform based on
tblIPData.
On the main form I put a command button that makes the subform popup
however
it is not pulling the IDTag # into the subform.


I get the following error....
Syntax error (missing operator0 in query expression
'[EIDTag]=12KZ791'.
 

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