473,748 Members | 8,760 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referencing to form's field value in query

In my query I'm trying to reference to a numeric (autonumber) field of my
form but I can't get it to work. Error message: "Datatypes don't match in
the criterium expression."
This is the particular line that doesn't work:

strSQL = strSQL & "WHERE (((Contact.ID_c ontact)='" & Me.ID_contact] & "'));"

When I replace '" & Me.ID_contact] & "' by 1 it works. I tried removing and
replacing the quotes in all kinds of ways, but no luck.

The '" & Me.ID_contact] & "' has always worked for me on text fields.

Can someone enlighten me?
Thanks in advance,
john
Feb 24 '07 #1
2 8307
Try:
strSQL = strSQL & "WHERE (Contact.[ID_contact] = " & _
Nz(Me.[ID_contact],0) & ");"

That:
- Removes the quotes (which are not required as delimiters on Number
fields.)
- Fixes the mismatched square brackets.
- Handles the case where the text box might is null (e.g. at a new record.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John" <jo@hn.comwro te in message
news:er******** ***@textnews.wa nadoo.nl...
In my query I'm trying to reference to a numeric (autonumber) field of my
form but I can't get it to work. Error message: "Datatypes don't match in
the criterium expression."
This is the particular line that doesn't work:

strSQL = strSQL & "WHERE (((Contact.ID_c ontact)='" & Me.ID_contact] &
"'));"

When I replace '" & Me.ID_contact] & "' by 1 it works. I tried removing
and replacing the quotes in all kinds of ways, but no luck.

The '" & Me.ID_contact] & "' has always worked for me on text fields.

Can someone enlighten me?
Thanks in advance,
john
Feb 24 '07 #2
Excellent! thanks a lot.
john

"Allen Browne" <Al*********@Se eSig.Invalidsch reef in bericht
news:45******** **************@ per-qv1-newsreader-01.iinet.net.au ...
Try:
strSQL = strSQL & "WHERE (Contact.[ID_contact] = " & _
Nz(Me.[ID_contact],0) & ");"

That:
- Removes the quotes (which are not required as delimiters on Number
fields.)
- Fixes the mismatched square brackets.
- Handles the case where the text box might is null (e.g. at a new
record.)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"John" <jo@hn.comwro te in message
news:er******** ***@textnews.wa nadoo.nl...
>In my query I'm trying to reference to a numeric (autonumber) field of my
form but I can't get it to work. Error message: "Datatypes don't match in
the criterium expression."
This is the particular line that doesn't work:

strSQL = strSQL & "WHERE (((Contact.ID_c ontact)='" & Me.ID_contact] &
"'));"

When I replace '" & Me.ID_contact] & "' by 1 it works. I tried removing
and replacing the quotes in all kinds of ways, but no luck.

The '" & Me.ID_contact] & "' has always worked for me on text fields.

Can someone enlighten me?
Thanks in advance,
john

Feb 24 '07 #3

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

Similar topics

2
4765
by: William Wisnieski | last post by:
Hello Everyone, Access 2000 I have a main form with a continuous subform. On the main form I have a text box that references a field on the subform. What I'd like it to do is show the value in the field of the last record entered on the subform. But what its doing is referencing whatever record the user clicked on last before closing all the forms. Also if the user cleared the subform field, I would like the text box on the main...
25
10257
by: Lyn | last post by:
Hi, I am working on a genealogy form. The only table (so far) lists everybody in the family, one record per person. Each record has an autonum ID. The parent form (frmMainForm) displays the data in each record, which includes the ID of the father and the mother (who also have records in the table). One record per form. I have a Tab Control in the form, and in one of the tabs I have a subform (sfmSiblings) in which I wish to list...
5
5259
by: tdmailbox | last post by:
I have a form with a child form. In the child form there is a list of names that can grow quite large. On the parent form I want to display the first name from the child form. I set up a test box that is populated with the code =subfrm_media_review_sec_party.Form!first_name & " " & subfrm_media_review_sec_party.Form!last_name It works except that when I flip through the names it populates the parent form with the name of what ever...
2
2419
by: Rooksarii | last post by:
Hello folks, Let me first apologize for any impropper terminology I may use as I am presently trying to broaden my Office knowledge by diving into Access head on. My specific problem is this. I have a field in one of my tables that references a value in another table via a list box. Next to it, instead of manually creating another list box to go along with it, I would like to have this other field acknowledge that the value in it's...
3
2789
by: shumaker | last post by:
This code from the subform works for getting the value of a field of the main form named "WorkSheet": MsgBox Form_WorkSheet.Recordset.Fields("Clerk").Value Each record in the mainform datasheet called "WorkSheet" has a subform. I am trying to get the controls on the subform to reference the fields in the main form, because I think that it will resolve some of my write conflict problems by not having a recordset for the subform, and...
6
2399
by: George Slamowitz | last post by:
Hello all I have a HTML control generated by the following: INPUT TYPE="hidden" NAME="MyAnswer" VALUE="" Is there a way to reference the Value of this control using VB program code??? Thanks in advance
11
3524
by: ozTinker | last post by:
I'm sure this shouldn't be too difficult, but I lack familiarity with the MS object model. Suppose I have a table "Purchase_Orders" and a form "TEMP" which I am using to look up a customer's orders. The form has a text field named LastName for typing in new orders, but first let's look at the previous orders. Elsewhere on the form is a Office Web Components Spreadsheet version 11.0, which will run a query and show the result list. The...
2
1929
by: sbettadpur | last post by:
Hi everybody, Hi iam strugling with more than one submit buttons with in one form here is my code <form method="post" action="Offer.php" name='issueFrm' onSubmit="return fullOfferfields();"> OFFER <input type=image src="amarok_rewind.png " title="rewind" > <input type=image src="amarok_back.png" title="back"> <input type="text" size=3 name='txt'>&nbsp;<input type=image src="amarok_next.png " title="next" >&nbsp;<input type=image...
8
2183
by: angi35 | last post by:
Hi all - I've been working on this from various angles for days, and I'm pretty well stumped at this point. Hope someone has some ideas. Working in Access 2000... I’m trying to write code to assign a 3-part identifier to each new record. The 3 parts are: BidNumPt1: two-digit current year (BidNumPt1 = Format(Date, “yy”)) BidNumPt2: three-digit incremental number based on the year (Pt1) and the salesperson (Pt3) BidNumPt3: one-digit...
0
9548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9325
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8244
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6796
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4607
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3315
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 we have to send another system
2
2787
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2215
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.