473,772 Members | 2,564 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Need to verify data exists in another table

2 New Member
Good morning. I have two tables (Batches) and (Archive). (Batches) is a linked table that contains all of the existing data and the other (Archive) I am keying data into, through a form. I want to be able to key into a form that writes to (Archive), but before it saves or moves to the next field, I want to make sure that the data already exists in (Batches) and prompt the user if it doesn't. The reason being is that I don't want to save any records in (Archive) that don't exist in (Batches). Also, just to be clear. There is only one field [BatchID] that I want to be able to check between the two tables.

Thanks,
Kelly
Apr 25 '07 #1
3 5234
MMcCarthy
14,534 Recognized Expert Moderator MVP
Hi Kelly

In the After Update of BatchID on the form bound to the Archive table put the following:

Expand|Select|Wrap|Line Numbers
  1. Private Sub BatchID_AfterUpdate()
  2. Dim tmpBID As Long
  3.  
  4.    tmpBID = nz(DLookup("[BatchID]","Batches","[BatchID]=" & Me!BatchID),0)
  5.    If tmpBID = 0 Then
  6.       Msgbox "This BatchID does not exist in table Batches"
  7.    End If
  8.  
  9. End Sub
  10.  
Mary
Apr 25 '07 #2
kchang77
2 New Member
What should I do if I want the message box to return a message if the value is null?


Hi Kelly

In the After Update of BatchID on the form bound to the Archive table put the following:

Expand|Select|Wrap|Line Numbers
  1. Private Sub BatchID_AfterUpdate()
  2. Dim tmpBID As Long
  3.  
  4.    tmpBID = nz(DLookup("[BatchID]","Batches","[BatchID]=" & Me!BatchID),0)
  5.    If tmpBID = 0 Then
  6.       Msgbox "This BatchID does not exist in table Batches"
  7.    End If
  8.  
  9. End Sub
  10.  
Mary
Apr 25 '07 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
What should I do if I want the message box to return a message if the value is null?
This will return a message if the value is null
Apr 25 '07 #4

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

Similar topics

0
4811
by: Redd | last post by:
The following is a technical report on a data modeling project that was recently assigned to me by my professor. I post it so that anyone else who is studying databases and data modeling can have an example to go by with their study of databases. I was assinged to come up with a data model, but I choose the Autoparts sales and inventory management schema. It you would like the SQL code to generate the schema or if you would like the ERWin...
9
3137
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be done in one efficient/fast query, but I can't think of one. In the case that one query is not...
4
4145
by: jeff brubaker | last post by:
Hello, Currently we have a database, and it is our desire for it to be able to store millions of records. The data in the table can be divided up by client, and it stores nothing but about 7 integers. | table | | id | clientId | int1 | int2 | int 3 | ... | Right now, our benchmarks indicate a drastic increase in performance if we divide the data into different tables. For example,...
0
1287
by: Moran | last post by:
I got trial software 60-days limit on use of Visual Studio .net Professional from Microsoft and I'm having trouble install it on my computer. While installing this program i got the following message: "Win\Microsoft.NET\Framework\URTInstallPath\System.Window s.Forms.xml. Verify that the file exists and that you can access it." I check and the file do not exist in the disk i got. i press the IGNORE button and i got the more massages:
2
1724
by: Sebastian | last post by:
The following query needs about 2 minutes to complete (finding dupes) on a table of about 10000 addresses. Does anyone have an idea on how to speed this up ? Thanks in advance !!! Sebastian
2
5265
by: Wayne Wengert | last post by:
I want to write a Windows application to go through all the email addresses in an SQL Server table and to report which ones are invalid. From Googling and perusing NGs it is my understanding that the process to validate an email address is done at 3 levels: 1. Verify that it is syntactically valid 2. Verify that the domain exists (SMTP verification) 3. Verify that the email address exists at that domain (MX verification) The first one I...
5
2728
by: Chris | last post by:
I have a meetings section I'm developing on our intranet. Using PHP/MySQL. Meeting info and Meeting docs reside on 2 related tables in the db. Users may want to upload anywhere from 1 to 10 or more documents to share/use during a meeting presentation. What would be the most efficient way to approach this? This is the logic I'm currently considering: Page 1: Meeting Information input with link to a document upload page (this page...
3
9500
by: jpr | last post by:
Hello, I have a form on which I have a cmdbutton to copy a couple of fields into another table (MASTER) using the SSN on the active form as criteria. In the active form (based on a tables called LIST) the ssn fields is named CN while in the table where I want to copy this record, the field is named SSN. Basically I am running an append query using code but would like to add a code that will verify if a record with a similar
9
3944
by: pic078 via AccessMonster.com | last post by:
I need serious help - I have a frontend/backend Access database (2 MDE Files) that remains stuck in task manager after exiting the application - you can't reopen database after exiting as a result - I have read every post out there and spent hours trying to figure out the problem with no success whatsoever - I have constrained the problem to one form however, and I think it's hiding somewhere in my code associated with this form, which is...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
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
10106
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
10039
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
9914
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5355
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
4009
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
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
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.