Missing Operator in Query Expression

H

Hank

Whats is wrong with the following. I am trying to open a form and display the
correct record based on the value of a combobox. I also need all of the
records to appear in the opened form so additional entries can be made but
would like it to open with the correct record shown

Code Follows:

Private Sub CustCmb_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
Dim stDocName As String

stLinkCriteria = "[CompanyName] = " & Me.CustCmb & ""
stDocName = "Customers"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

Thank Everyone for all of your assistance. I am still learning!!
 
C

Crystal (strive4peace)

Hi Hank,

first, the form will open filtered ... but I am assuming that
CompanyName is text, so to make the filter work properly, the value in
CustCmb needs to be delimited with quotes if it is text

tLinkCriteria = "[CompanyName] = '" & Me.CustCmb & "'"

BUT this will not let you see other records unless you remove the filter
once it is open

btw, you should be using something other than the company name as a
primary key ...read this:

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page tutorial that covers essentials in Access


Warm Regards,
Crystal
remote programming and training

http://www.YouTube.com/user/LearnAccessByCrystal

*
:) have an awesome day :)
*
 
H

Hank

Thanks Crystal,

That did open the form. How do I remove the filter now that it opens?

Crystal (strive4peace) said:
Hi Hank,

first, the form will open filtered ... but I am assuming that
CompanyName is text, so to make the filter work properly, the value in
CustCmb needs to be delimited with quotes if it is text

tLinkCriteria = "[CompanyName] = '" & Me.CustCmb & "'"

BUT this will not let you see other records unless you remove the filter
once it is open

btw, you should be using something other than the company name as a
primary key ...read this:

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page tutorial that covers essentials in Access


Warm Regards,
Crystal
remote programming and training

http://www.YouTube.com/user/LearnAccessByCrystal

*
:) have an awesome day :)
*

Whats is wrong with the following. I am trying to open a form and display the
correct record based on the value of a combobox. I also need all of the
records to appear in the opened form so additional entries can be made but
would like it to open with the correct record shown

Code Follows:

Private Sub CustCmb_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
Dim stDocName As String

stLinkCriteria = "[CompanyName] = " & Me.CustCmb & ""
stDocName = "Customers"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

Thank Everyone for all of your assistance. I am still learning!!
 
C

Crystal (strive4peace)

Hi Hank,

what version of Access are you using?


Warm Regards,
Crystal
remote programming and training

http://www.YouTube.com/user/LearnAccessByCrystal

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page tutorial that covers essentials in Access

*
:) have an awesome day :)
*

Thanks Crystal,

That did open the form. How do I remove the filter now that it opens?

Crystal (strive4peace) said:
Hi Hank,

first, the form will open filtered ... but I am assuming that
CompanyName is text, so to make the filter work properly, the value in
CustCmb needs to be delimited with quotes if it is text

tLinkCriteria = "[CompanyName] = '" & Me.CustCmb & "'"

BUT this will not let you see other records unless you remove the filter
once it is open

btw, you should be using something other than the company name as a
primary key ...read this:

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page tutorial that covers essentials in Access


Warm Regards,
Crystal
remote programming and training

http://www.YouTube.com/user/LearnAccessByCrystal

*
:) have an awesome day :)
*

Whats is wrong with the following. I am trying to open a form and display the
correct record based on the value of a combobox. I also need all of the
records to appear in the opened form so additional entries can be made but
would like it to open with the correct record shown

Code Follows:

Private Sub CustCmb_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
Dim stDocName As String

stLinkCriteria = "[CompanyName] = " & Me.CustCmb & ""
stDocName = "Customers"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

Thank Everyone for all of your assistance. I am still learning!!
 
H

Hank

I am Using Access 2003.
Have tried to figure out how to turn off the filter but when it does turn
off it instantly goes to the 1st record.

Thanks for your help with this!!!

Crystal (strive4peace) said:
Hi Hank,

what version of Access are you using?


Warm Regards,
Crystal
remote programming and training

http://www.YouTube.com/user/LearnAccessByCrystal

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page tutorial that covers essentials in Access

*
:) have an awesome day :)
*

Thanks Crystal,

That did open the form. How do I remove the filter now that it opens?

Crystal (strive4peace) said:
Hi Hank,

first, the form will open filtered ... but I am assuming that
CompanyName is text, so to make the filter work properly, the value in
CustCmb needs to be delimited with quotes if it is text

tLinkCriteria = "[CompanyName] = '" & Me.CustCmb & "'"

BUT this will not let you see other records unless you remove the filter
once it is open

btw, you should be using something other than the company name as a
primary key ...read this:

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page tutorial that covers essentials in Access


Warm Regards,
Crystal
remote programming and training

http://www.YouTube.com/user/LearnAccessByCrystal

*
:) have an awesome day :)
*


Hank wrote:
Whats is wrong with the following. I am trying to open a form and display the
correct record based on the value of a combobox. I also need all of the
records to appear in the opened form so additional entries can be made but
would like it to open with the correct record shown

Code Follows:

Private Sub CustCmb_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
Dim stDocName As String

stLinkCriteria = "[CompanyName] = " & Me.CustCmb & ""
stDocName = "Customers"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

Thank Everyone for all of your assistance. I am still learning!!
 
C

Crystal (strive4peace)

Hi Hank,

you're welcome ;)

when the form is opened, it is filtered and, in that case, there is a
filter icon that looks like a funnel on the toolbar. It will be
depressed, indicating that there is a filter on. Click the button again
to remove the filter.

Also, at the bottom of the form, in the lower left after the nagigation
buttons, you will see a "filtered" indicator if the form is filtered.

Personally, what I do is use the OpenArgs function to pass the primary
key, then use the Load event of the form to test to see if a number was
passed and, if so, attempt to find the record -- but that might be too
much coding for you right now...

Warm Regards,
Crystal
remote programming and training

http://www.YouTube.com/user/LearnAccessByCrystal

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page tutorial that covers essentials in Access

*
:) have an awesome day :)
*

I am Using Access 2003.
Have tried to figure out how to turn off the filter but when it does turn
off it instantly goes to the 1st record.

Thanks for your help with this!!!

Crystal (strive4peace) said:
Hi Hank,

what version of Access are you using?


Warm Regards,
Crystal
remote programming and training

http://www.YouTube.com/user/LearnAccessByCrystal

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page tutorial that covers essentials in Access

*
:) have an awesome day :)
*

Thanks Crystal,

That did open the form. How do I remove the filter now that it opens?

:

Hi Hank,

first, the form will open filtered ... but I am assuming that
CompanyName is text, so to make the filter work properly, the value in
CustCmb needs to be delimited with quotes if it is text

tLinkCriteria = "[CompanyName] = '" & Me.CustCmb & "'"

BUT this will not let you see other records unless you remove the filter
once it is open

btw, you should be using something other than the company name as a
primary key ...read this:

Access Basics
http://www.AccessMVP.com/strive4peace
free 100-page tutorial that covers essentials in Access


Warm Regards,
Crystal
remote programming and training

http://www.YouTube.com/user/LearnAccessByCrystal

*
:) have an awesome day :)
*


Hank wrote:
Whats is wrong with the following. I am trying to open a form and display the
correct record based on the value of a combobox. I also need all of the
records to appear in the opened form so additional entries can be made but
would like it to open with the correct record shown

Code Follows:

Private Sub CustCmb_DblClick(Cancel As Integer)
Dim stLinkCriteria As String
Dim stDocName As String

stLinkCriteria = "[CompanyName] = " & Me.CustCmb & ""
stDocName = "Customers"
DoCmd.OpenForm stDocName, , , stLinkCriteria
End Sub

Thank Everyone for all of your assistance. I am still learning!!
 

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

Similar Threads


Top