473,498 Members | 1,737 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Syntax error

I need some fresh eyes to take a look at this code for me and let me
know what it is I'm doing wrong because I keep getting all kinds of
error message with this code. I've had several people help me with this
code and every thing that've told me I've done but for the life of me I
can't seem to get this working right.
First I keep getting "Type mismatch" error message for this line of
code: StrProject = Str(Me!cboProjectID) but if I take out the str and
just have strProject = Me!cboProjectID it's fine.
Second I keep getting "Syntax error(missing operator) in experience in
this line of code:
rst.FindFirst "[cboProjectID] = '" & StrProject & "'" &
"[cboJurisdiction] ='" & StrState

This is the complete code:
Private Sub cmdFind_Click()
Dim rst As DAO.Recordset
Dim StrProject As String
Dim StrState As String

Set rst = Me.RecordsetClone

StrProject = Str(Me!cboProjectID)
StrState = Str(Me!cboJurisdiction)
rst.FindFirst "[cboProjectID] = '" & StrProject & "'" &
"[cboJurisdiction] ='" & StrState
If Not rst.NoMatch Then

MsgBox "Record Found"
Else
MsgBox "Not Found"

End If

Set rst = Nothing

End Sub

I've cross checked my code with other people code and it looks the
same, I also use the help sample code but I keep getting this message.
I know I'm missing something just not sure what.
Any help will be greatly appreciated.

Nov 13 '05 #1
3 2642
For the first issue, can you change it to use CStr() instead of Str():
StrProject = CStr(Me!cboProjectID) ?

For the second, it looks like you are missing the end single quote. I
think it should be:

rst.FindFirst "[cboProjectID] = '" & StrProject & "'" &
"[cboJurisdiction] ='" & StrState & "'"

Hope this helps.

David Hodgkins, MCSD, MCDBA, MCSE
dh*******@jstarsoftware.com
www.jstarsoftware.com

Nov 13 '05 #2
> rst.FindFirst "[cboProjectID] = '" & StrProject & "'" &
"[cboJurisdiction] ='" & StrState
You are concatenating with & when you actually need the word "and" in the
string. You are also missing the ending quote.

rst.FindFirst "[cboProjectID] = '" & StrProject & "' And [cboJurisdiction]
='" & StrState & "'"

Also, why are you converting the cboProjectID to a string? While
cboProjectID may be the name of the combo box on the form, is it the name of
the field in the recordset, same question for cboJurisdiction? How many
columns are in the combo boxes? The value of the combo box will come from
the Bound Column which may not be the displayed column.

--
Wayne Morgan
MS Access MVP
"kufre" <ku********@yahoo.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...I need some fresh eyes to take a look at this code for me and let me
know what it is I'm doing wrong because I keep getting all kinds of
error message with this code. I've had several people help me with this
code and every thing that've told me I've done but for the life of me I
can't seem to get this working right.
First I keep getting "Type mismatch" error message for this line of
code: StrProject = Str(Me!cboProjectID) but if I take out the str and
just have strProject = Me!cboProjectID it's fine.
Second I keep getting "Syntax error(missing operator) in experience in
this line of code:
rst.FindFirst "[cboProjectID] = '" & StrProject & "'" &
"[cboJurisdiction] ='" & StrState

This is the complete code:
Private Sub cmdFind_Click()
Dim rst As DAO.Recordset
Dim StrProject As String
Dim StrState As String

Set rst = Me.RecordsetClone

StrProject = Str(Me!cboProjectID)
StrState = Str(Me!cboJurisdiction)
rst.FindFirst "[cboProjectID] = '" & StrProject & "'" &
"[cboJurisdiction] ='" & StrState
If Not rst.NoMatch Then

MsgBox "Record Found"
Else
MsgBox "Not Found"

End If

Set rst = Nothing

End Sub

I've cross checked my code with other people code and it looks the
same, I also use the help sample code but I keep getting this message.
I know I'm missing something just not sure what.
Any help will be greatly appreciated.

Nov 13 '05 #3
"kufre" <ku********@yahoo.com> wrote in
news:11*********************@o13g2000cwo.googlegro ups.com:
I need some fresh eyes to take a look at this code for me First I keep getting "Type mismatch" error message for this line of code: StrProject =
Str(Me!cboProjectID) but if I take out the str and just have
strProject = Me!cboProjectID it's fine.
are you trying to convert a number to a string? that should use
the cstr() function., but if cboprojectID is already a string,
that's unnecessary.
Second I keep getting "Syntax error(missing operator) in experience in this line of
code: rst.FindFirst "[cboProjectID] = '" & StrProject & "'" &
"[cboJurisdiction] ='" & StrState
You are missing an operator between "[cboProjectID] = '" &
StrProject and "[cboJurisdiction] ='" & StrState. I suggest the
and operator, which will give you
rst.FindFirst "[cboProjectID] = '" & StrProject & "' AND
[cboJurisdiction] ='" & StrState & "'"

I've cross checked my code with other people code and it looks
the same,
Not exactly the same. :-)

I also use the help sample code but I keep getting this message. I know I'm missing something just not sure what.
Any help will be greatly appreciated.


--
Bob Quintal

PA is y I've altered my email address.
Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3330
by: Steve | last post by:
I just spent waaaaaaaaaaaayy too much time trying to track down an error that was incorrectly reported just now, and I would like to see if someone can explain to me why it was reported that way. ...
1
3220
by: Donald Canton | last post by:
Hi, I'm using Bjarne's book to learn C++ and am stuck on the Calc program in Section 6. Everything works fine except when I try to use istringstream to parse a token from the command line. I...
5
4471
by: r.nikhilk | last post by:
Hi, Currently, we are porting C++ applications from 32 bit to 64 bit on AIX platform. (The current version of AIX is 5.3 and xlC verison is 8.0). We are able to compile the applications by...
2
2244
by: david | last post by:
Anyone could give me a hand about this syntax error? Thank you. David Source Code: Dim conn As New SqlConnection(strConn) Dim daAngio As New SqlDataAdapter(strSelectStatement, conn) 'Create a...
3
16188
by: Manuel | last post by:
I'm trying to compile glut 3.7.6 (dowbloaded from official site)using devc++. So I've imported the glut32.dsp into devc++, included manually some headers, and start to compile. It return a very...
1
2210
by: Hari Sekhon | last post by:
I've written an except hook into a script as shown below which works well for the most part and catches exceptions. import sys def myexcepthook(type,value,tb): do something ...
7
1822
by: Josh | last post by:
I have a lot of except Exception, e statements in my code, which poses some problems. One of the biggest is whenever I refactor even the triviallest thing in my code. I would like python to...
7
2862
by: bryant | last post by:
Hi all. I am new to ASP and working in Expression Web. The following query displays the information I need in the gridview for a single record. SELECT "OE_HDR"."ORD_NO", "OE_HDR"."CUST_NAM",...
6
37996
by: muby | last post by:
Hi everybody :) I'm modifying a C++ code in VC++ 2005 my code snippet void BandwidthAllocationScheduler::insert( Message* msg, BOOL* QueueIsFull,
5
4001
Banfa
by: Banfa | last post by:
So I have a little problem, I have a template class and that class contains a template function; now what I want to do is declare that function in the class (or indeed the entire class) as a friend...
0
7125
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
1
6887
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4910
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3085
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1419
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
291
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.