Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Want to thank those people who have made this forum such a valuable place to visit each day..."

Geography

Where in the world do Tek-Tips members come from?

SubForm Pass Value to check if Record Exists then Create New Record

adwyer (TechnicalUser)
4 Aug 12 7:47
Hi everyone.
Forgive me this is my first post, I am new to MS Access and just exploring VB and macros.
I have an existing external database that I can connect to but can’t modify (read only). I need to add some additional fields to enhance the functionality of this database and the reporting.
Therefore I have created a new table [ProspectAddtionalFieldsT] with a text field [ID] which needs to link the primary key from the existing external database to the table containing the additional fields I need for my reporting.
I have successfully created a search form [ProspectSmartSearch] that displays filtered records in a subform [ProspectSmartSearch subform], now I need to add the capability to CLICK on the “ProspectID” from within the subform to open a new form which passes the Primary Key from the external database (ProspectID) to the new table [ProspectAddftionalFieldsT] and enables me to add and maintain the additional data fields I require.
Issue
I need to check if the “ProspectID” already exists within my new table [ProspectAddftionalFieldsT], If it doesn’t I need to create the new record by passing the “ProspectID” to the new table form the existing subform. Alternatively if it already exists go to the form linked to the primary key.
I have done a lot of research and realise this can be done, but have got myself completely confused with so many similar but slightly different alternatives on addressing this very issue.
I hope this is clear, I lack to correct terminology to communicate exactly what I am attempting to achieve.
Thank you in advance.
Ant
PGAC (Programmer)
4 Aug 12 11:42
Hi adwyer,

Why not link the external table into you local database and create an append query to copy all external records into the local table? You could just copy the Primary key field. You can then run the append query before you start any work on your local database.

For this to work, the primary key in the external table must be imitated in your local table. Using a text field as a primary key is not good practice. Use an autonumber/long integer.

By definition primary keys are unique so the append query will not duplicate but you might get warnings about records that failed to copy (which will be records that already exist in your local table).

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close