473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Auto- Populate from Linked table

OKay here is the situation. I am creating an inspection log database and have previously created an Non-conformance database. I am trying to get the NCRno field to auto-populate after I update the qtyrej field. the procedure is that we receive the material, inspect it, then log it. The Inspector will get to the point of accepting or rejecting and click a control button that takes them to a form that is has a linked table to enter the non-conformance in the other db. Okay here is the code I am using to autopopulate the NCR number field.
Expand|Select|Wrap|Line Numbers
  1. Private Sub QtyRej_AfterUpdate()
  2.  
  3.    Me.NCRNo = DLookup("[rptNumber]", "tblMaster", "[Date]=" & Me.DATE & " AND [ptNumber]=" & Me.PtNo)
  4.  
  5. End Sub 
when I do this I receive the following error: Run-Time Error '3464': Data Type Mis-match in criteria expression. don't have a clue what this means or how to fix it. Tried to give as much info as possible. tblMaster is the linked table.
Dec 15 '06 #1
2 2559
MMcCarthy
14,534 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. Private Sub QtyRej_AfterUpdate()
  2.  
  3.    Me.NCRNo = DLookup("[rptNumber]", "tblMaster", "[Date]=" & Me.DATE & " AND [ptNumber]=" & Me.PtNo)
  4.  
  5. End Sub 
Assuming Me.Date is a Control on the form you need to enclose it in # characters. Also as Date is a VBA function you need to surround it with square brackets. (Ideally change date to something else in the table and form). If ptNo is not a number but a text field then you will have to enclose it with single quotes like the date example.

Expand|Select|Wrap|Line Numbers
  1. Private Sub QtyRej_AfterUpdate()
  2.  
  3.    Me.NCRNo = DLookup("[rptNumber]", "tblMaster", "[Date]=#" & Me.[DATE] & "# AND [ptNumber]=" & Me.PtNo)
  4.  
  5. End Sub 
Mary
Dec 15 '06 #2
NeoPa
32,556 Expert Mod 16PB
There is also a requirement to format the 'literal' date as m/d/y (Only SQL supported Standard).
Shamelessly plagiarising Mary's code, here is a converted version.
Expand|Select|Wrap|Line Numbers
  1. Private Sub QtyRej_AfterUpdate()
  2.  
  3.    Me.NCRNo = DLookup("[rptNumber]", "tblMaster", "[Date]=" & Format(Me.[DATE],'\#m/d/yyyy\#') & " AND [ptNumber]=" & Me.PtNo)
  4.  
  5. End Sub
If you want an explanation of what does what with dates etc in queries, see (Literal DateTimes and Their Delimiters (#).)
Dec 16 '06 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Manlio Perillo | last post by:
Hi. This post follows "does python have useless destructors". I'm not an expert, so I hope what I will write is meaningfull and clear. Actually in Python there is no possibility to write code...
1
by: Lew | last post by:
Hi all, I'm trying to create a page that has a user-selectable page auto-refresh option (IE 5.5). Essentially, it's a page that contains a checkbox, when the user checks the checkbox, I'd like...
1
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the...
5
by: Robert Downes | last post by:
I'm using the following in a page that I'm testing in Mozilla: p.actionLinkBlock {border: 1px #000000 dashed; padding: 0.2cm; width: auto} But the dashed border is extending to the right-edge...
20
by: Vijay Kumar R. Zanvar | last post by:
Hello, Unlike register, auto keyword can not be used to declare formal parameter(s). Is there any specific reason for this? Kind regards, Vijay Kumar R. Zanvar
5
by: Samuel | last post by:
Hi, I am running into a problem of mixing UICulture = auto and allowing users to select culture using a dropdown list. I am detecting a querystring, "setlang", and when found, setting the...
5
by: maya | last post by:
at work they decided to center divs thus: body {text-align:center} #content {width: 612px; text-align:left; margin: 0 auto 0 auto; } this works fine in IE & FF, EXCEPT in FF it doesn't work if...
22
by: nospam_news | last post by:
I currently get asked about my usage of "auto". What is it for? The keyword is clearly superflous here. In contrast to the huge majority of C/C++ developers I write definitions very explicitly...
2
by: Piotr K | last post by:
Hi, I've encountered a strange problem with Firefox which I don't have any idea how to resolve. To the point: I've <divelement with a style "height: auto" and I want to retrieve this value...
21
by: JOYCE | last post by:
Look the subject,that's my problem! I hope someone can help me, thanks
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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,...

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.