IDNumber is not matching on other screens

G

Guest

I have 2 forms where I need to continue the text with the IDNumber on each
form. I tried the following but it's coming up with a "Compile Error -
Invalid use of Property". (stWhere = "[CTANumber] = " & Me!Number_Text)

Private Sub Additional_Contacts_Click()
On Error GoTo Err_Additional_Contacts_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stWhere As SubForm

stDocName = "frm_CTAContactsView"
stWhere = "[CTANumber] = " & Me!Number_Text
DoCmd.OpenForm stDocName, stWhere, stLinkCriteria

Exit_Additional_Contacts_Click:
Exit Sub

Err_Additional_Contacts_Click:
MsgBox Err.Description
Resume Exit_Additional_Contacts_Click

End Sub

Could someone be so kind and tell me whats wrong with this?
 
T

Tom

Is Me!Number_Text a text field you must enclose it in quotation marks.
ie.
stWhere = "[CTANumber] = '" & Me!Number_Text & "'"

Also, the parameters to the DoCmd.OpenForm statement seem wrong
Try
DoCmd.OpenForm stDocName , acNormal, , stWhere
 
G

Guest

Well I just tried this and it still comes up with the same error message.
I've even changed it to where it says "Dim stWhere As SubForm" to Form as
this is a popup form not a Subform. Still get the same message. Here is
what I have now:

Private Sub Additional_Contacts_Click()
On Error GoTo Err_Additional_Contacts_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stWhere As Form

stDocName = "frm_CTAContactsView"
stWhere = "[CTANumber] = '" & Me!Number_Text & "'"
DoCmd.OpenForm stDocName, acNormal, stLinkCriteria, stWhere

Exit_Additional_Contacts_Click:
Exit Sub

Err_Additional_Contacts_Click:
MsgBox Err.Description
Resume Exit_Additional_Contacts_Click

End Sub

Any ideas?


Tom said:
Is Me!Number_Text a text field you must enclose it in quotation marks.
ie.
stWhere = "[CTANumber] = '" & Me!Number_Text & "'"

Also, the parameters to the DoCmd.OpenForm statement seem wrong
Try
DoCmd.OpenForm stDocName , acNormal, , stWhere

melwester said:
I have 2 forms where I need to continue the text with the IDNumber on each
form. I tried the following but it's coming up with a "Compile Error -
Invalid use of Property". (stWhere = "[CTANumber] = " & Me!Number_Text)

Private Sub Additional_Contacts_Click()
On Error GoTo Err_Additional_Contacts_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stWhere As SubForm

stDocName = "frm_CTAContactsView"
stWhere = "[CTANumber] = " & Me!Number_Text
DoCmd.OpenForm stDocName, stWhere, stLinkCriteria

Exit_Additional_Contacts_Click:
Exit Sub

Err_Additional_Contacts_Click:
MsgBox Err.Description
Resume Exit_Additional_Contacts_Click

End Sub

Could someone be so kind and tell me whats wrong with this?
 
D

Douglas J Steele

stWhere is neither a form nor a subform: it's a string. It holds the WHERE
clause to be used when opening the form. Change your code to:

Dim stWhere As String


(FWIW, there is no actual subform object in Access: a subform is just a
particular way of using a form)

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


melwester said:
Well I just tried this and it still comes up with the same error message.
I've even changed it to where it says "Dim stWhere As SubForm" to Form as
this is a popup form not a Subform. Still get the same message. Here is
what I have now:

Private Sub Additional_Contacts_Click()
On Error GoTo Err_Additional_Contacts_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stWhere As Form

stDocName = "frm_CTAContactsView"
stWhere = "[CTANumber] = '" & Me!Number_Text & "'"
DoCmd.OpenForm stDocName, acNormal, stLinkCriteria, stWhere

Exit_Additional_Contacts_Click:
Exit Sub

Err_Additional_Contacts_Click:
MsgBox Err.Description
Resume Exit_Additional_Contacts_Click

End Sub

Any ideas?


Tom said:
Is Me!Number_Text a text field you must enclose it in quotation marks.
ie.
stWhere = "[CTANumber] = '" & Me!Number_Text & "'"

Also, the parameters to the DoCmd.OpenForm statement seem wrong
Try
DoCmd.OpenForm stDocName , acNormal, , stWhere

melwester said:
I have 2 forms where I need to continue the text with the IDNumber on each
form. I tried the following but it's coming up with a "Compile Error -
Invalid use of Property". (stWhere = "[CTANumber] = " & Me!Number_Text)

Private Sub Additional_Contacts_Click()
On Error GoTo Err_Additional_Contacts_Click

Dim stDocName As String
Dim stLinkCriteria As String
Dim stWhere As SubForm

stDocName = "frm_CTAContactsView"
stWhere = "[CTANumber] = " & Me!Number_Text
DoCmd.OpenForm stDocName, stWhere, stLinkCriteria

Exit_Additional_Contacts_Click:
Exit Sub

Err_Additional_Contacts_Click:
MsgBox Err.Description
Resume Exit_Additional_Contacts_Click

End Sub

Could someone be so kind and tell me whats wrong with this?
 

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