473,513 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Should be easy... checking for an existing record

6 New Member
Hi all, I need help on something that seems like it should be easy to do.

When entering new data onto any form in my database the field [SubNo] has to exist in another table (tblPatients). If a SubNo is entered that isn't already on tblPatients, I want it to open the form frmNewPatient to add the patient to tblPatients; If the SubNo is already in tblPatients, I want it to do nothing. I can't figure out what the condition should be in a macro to make this happen. Any suggestions?

Thanks!!

Cheryl
Aug 22 '07 #1
1 993
Jim Doherty
897 Recognized Expert Contributor
Hi all, I need help on something that seems like it should be easy to do.

When entering new data onto any form in my database the field [SubNo] has to exist in another table (tblPatients). If a SubNo is entered that isn't already on tblPatients, I want it to open the form frmNewPatient to add the patient to tblPatients; If the SubNo is already in tblPatients, I want it to do nothing. I can't figure out what the condition should be in a macro to make this happen. Any suggestions?

Thanks!!

Cheryl
Cheryl

There are a number of ways you can do this. Depending on the design of your database (in terms of the SQL statement supporting the recordsource of your form) ie: you could have a query as the recordsource, where the query is a combination of the patients table and whatever table you are actually entering data into. In this scenario there would need to be a one to many relationship defined between the primary key (presumably SubNo) in the patients table and the SubNo (Foreign key) in the table you are actually entering data into.

The practical effect of this visibly on screen is that the moment you enter a subno into the subno field on the form Access 'automatically' looksup the value of that which you have typed in, and returns any match in the patients table.

You see the practical effect of this if you place the patients table (subno) on the form also. You would test for where there was nothing returned ie: a NULL value in the 'after update' event of of the subNo field and if so display a message box prompting that their exists No such patient having the number just entered and displaying a pop up form to enter the values for a new patient

Bottom line! look at the AUTO LOOKUP feature of Access it may be all you need in this scenario

Jim
Aug 22 '07 #2

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

Similar topics

40
2987
by: Steve Juranich | last post by:
I know that this topic has the potential for blowing up in my face, but I can't help asking. I've been using Python since 1.5.1, so I'm not what you'd call a "n00b". I dutifully evangelize on the...
5
3056
by: Sue | last post by:
As soon as a character is entered in the first field of a new record, the number of records shown in the navigation buttons increases by 1 and the new record button becomes enabled. In the...
2
2821
by: R Bolling | last post by:
I am using a routine to check to see if a phone number (PK) has alread been entered, and takes the user to that record if it is found -- as follows: Private Sub...
4
2720
by: Andy Proctor | last post by:
I hope there is an answer out there.... I have a simple database structured like this (non relevant tables and fields omitted) Members table memberID memberFname memberLname memberNokID
6
1857
by: John | last post by:
Hi We have a staff database and need to make sure that the same staff is not entered twice. Is there a way for Access to flag if combination of forename and surname fields is already in the...
5
23026
by: BerkshireGuy | last post by:
Hello everyone, I have a bond form that a user uses to enter data. One of my fields, is PolicyNumber. I added some code on the Before Update event of txtPolicyNumber that checks to see if...
2
1729
by: Mark Perona | last post by:
I created an ASP.net form with an editable datagrid on it. I can create new records, and update and delete existing records. The problem I have is that I want a field in the grid to be editible...
1
4913
by: Mad Scientist Jr | last post by:
can someone explain how to simply populate a grid in .net ? the way i understand it, there is no more msflexgrid, and instead is this new control that has to be tied to a dataset, and it is a real...
2
1441
by: Cheryl.D.Monroe | last post by:
Hi all, I need help on something that seems like it should be easy to do. When entering new data onto any form in my database the field has to exist in another table (tblPatients). If a SubNo...
0
7267
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,...
0
7542
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
5697
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
5100
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
3247
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
3235
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1609
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
809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
466
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.