Connecting Tech Pros Worldwide Help | Site Map

Should be easy... checking for an existing record

 
LinkBack Thread Tools Search this Thread
  #1  
Old August 22nd, 2007, 08:35 PM
Cheryl.D.Monroe@gmail.com
Guest
 
Posts: n/a
Default Should be easy... checking for an existing record

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


  #2  
Old August 22nd, 2007, 11:45 PM
Steve
Guest
 
Posts: n/a
Default Re: Should be easy... checking for an existing record

Put the following code in AfterUpdate event of [SubNo]:

If DCount("[SubNo]","TblPatients","[SubNo] = " &
Forms!NameOfYourForm![SubNo]) = 0 Then
DoCmd.OpenForm "FrmNewPatient"
End If

The above assumes [SubNo] is numeric. If it is text, change the first line
to:
If DCount("[SubNo]","TblPatients","[SubNo] = '" &
Forms!NameOfYourForm![SubNo] & "'") = 0 Then

PC Datasheet
Providing Customers A Resource For Help With Access, Excel And Word
Applications
resource@pcdatasheet.com


<Cheryl.D.Monroe@gmail.comwrote in message
news:1187814332.893854.271910@i13g2000prf.googlegr oups.com...
Quote:
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
>

  #3  
Old August 23rd, 2007, 07:35 AM
StopThisAdvertising
Guest
 
Posts: n/a
Default Re: Should be easy... checking for an existing record


"Steve" <sorry@private.emailaddressschreef in bericht news:13cpi9o4t55ssea@corp.supernews.com...
Quote:
Put the following code in AfterUpdate event of [SubNo]:

If DCount("[SubNo]","TblPatients","[SubNo] = " &
Forms!NameOfYourForm![SubNo]) = 0 Then
DoCmd.OpenForm "FrmNewPatient"
End If

The above assumes [SubNo] is numeric. If it is text, change the first line
to:
If DCount("[SubNo]","TblPatients","[SubNo] = '" &
Forms!NameOfYourForm![SubNo] & "'") = 0 Then

PC Datasheet

--
This is to inform 'newbees' here about PCD' Steve:
http://home.tiscali.nl/arracom/whoissteve.html
Until now 3650+ pageloads, 2350+ first-time visitors (these figures are rapidly increasing)

Why is this ???
Because Steve is the ONLY person here who continues to advertise in the groups.

It is not relevant whether he advertised in *this* particular post or not...
==We want him to know that these groups are *not* his private hunting grounds!

For those who don't like too see all these messages:
==Simply killfile 'StopThisAdvertising'.
Newbees will still see this warning-message.

ArnoR
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.