473,767 Members | 2,226 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Code to add and verify existing data

jpr
Hello,
I need some help. I have a form named MASTER based on a table also
called MASTER.
A control of my form in names SSN which stores the client SSN.

On the same form I have placed a subform which has its record source to
a table named 21.

What I am trying to do is:
When I enter a new record in my form MASTER, the code should:
1) Verify if in table 21 a record with that SSN already exists.
If YES, skip the code and do not add the SSN. If NO, well, run the
appendquery.

2) At the same time, verify if a record with that SSN already exists in
table MASTER. If NO, add the data, if YES, abort the code and exit the
form.

The form EForms is a menu form I use to access the records.
This is the code. Something is not going right, I think with the end if
functions. Any help? I have placed the code in the AfterUpdate event of
my control SSN.

Dim mydb As DAO.Database, MyRs As DAO.Recordset
Dim strCode As String
Dim strFilter As String
Dim stDocName As String
Dim stLinkCriteria As String

Set mydb = CurrentDb
Set MyRs = mydb.OpenRecord set("master")

stDocName = "MASTER"

stLinkCriteria = "[SSN]=" & "'" & Me![SSN] & "'"

DoCmd.OpenForm stDocName, , , stLinkCriteria

If Not IsNull(DLookup( "[SSN]", "21", "[SSN] = '" & Me!SSN & "'")) Then
Forms("EFORMS") .Visible = False
Else
If IsNull(DLookup( "[SSN]", "21", "[SSN] = '" & Me!SSN & "'")) Then
DoCmd.OpenQuery ("Appendssa21ta x")
End If
End If

If Not IsNull(DLookup( "[SSN]", "MASTER", "[SSN] = '" & Me!SSN & "'"))
Then
MsgBox "Sorry! A record with this SSN is already in file. Retrive case
from E-Forms Menu.", vbOKOnly, "Warning"
DoCmd.DoMenuIte m acFormBar, acEditMenu, acUndo, , acMenuVer70
DoCmd.Close
End If
Forms!eforms.ls tPreInterview.V alue = Null
DoCmd.Close
DoCmd.OpenForm ("Eforms")
DoCmd.RunMacro ("CloseEform s")
DoCmd.OpenForm ("Eforms")
End If

Thanks.

May 31 '06 #1
0 1428

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

Similar topics

10
5724
by: bsandell | last post by:
I need to write a stored procedure to verify that a table exists and also that the user executing the stored procedure has access to the specified table. Any user can call this publicly available procedure and pass a database name, an owner name and a table name as parameters. The procedure returns success if the table exists and the user has access to it, or fails if he doesn't. Here's a simplified version of what I have, but I'm...
1
4280
by: David Smith | last post by:
What I want to be able to do: A textbox is available that the user can enter information into. Specifically (for the purposes of this post), the user is asked to enter a number, and that number has an upper limit. I want to do validation on what the user enters as they type it in. I set up an event handler for KeyPress that restricts them from being able to enter non-numeric characters (only allowing numbers, decimal point, control...
3
2297
by: Ryan Liu | last post by:
Can someone give a sample to prevent a row from being deleted in a datatable? I tried e.Row.RejectChanges(); in dt_RowDeleting() but seems does not work. I need verify if there other data using data in this row before actually remove it from datagrid. I can certainly control with Delete button. But if I want to allow the user to use Del key on the keyboard, I lost this kind control.
1
1103
by: Tom Bianchi | last post by:
Hi, I am using VS2005. I have a form that I use both to insert new records and modify existing records. I want that if the user tries to close the form, the application asks the user to save changes only if the record has actually changed. The problem is that if I use EndEdit, an existing record that has been modified becomes "Modified" (that's ok), but a new record after EndEdit becomes "Added", whether it has been modified by the user...
19
2006
by: Ingo Linkweiler | last post by:
Has anyone a function/script to verify an e-mail-address? It should: a) check the syntax b) verify an existing mailserver or DNS/MX records ingo
232
13338
by: robert maas, see http://tinyurl.com/uh3t | last post by:
I'm working on examples of programming in several languages, all (except PHP) running under CGI so that I can show both the source files and the actually running of the examples online. The first set of examples, after decoding the HTML FORM contents, merely verifies the text within a field to make sure it is a valid representation of an integer, without any junk thrown in, i.e. it must satisfy the regular expression: ^ *?+ *$ If the...
3
5232
by: kchang77 | last post by:
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...
1
1280
by: donut | last post by:
Hi, i am currently preparing a Data Migration Plan for migration of existing data from ADABAS to DB2. The data volume can be as huge as 200 GB. Since it is impossible to verify all the data migrated, does anyone know of any industry practices for the percentage of data to be verified for certain record size. For example, small sys: 0 to 1million records (1%) medium sys: 1 to 10million records (5%) large sys: 10million records and above...
1
2153
by: netrudra2 | last post by:
The following code is not working.it gives the same error messege as it gives when program specified for win95/98 is run. #include <stdio.h> #include <conio.h> #include <windows.h> #include <string.h> #include <io.h> #include <stdafx.h> #include <windows.h>
0
9571
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9404
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
10168
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
10009
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
7381
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
6651
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5279
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
3929
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
3
2806
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.