473,386 Members | 1,752 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Access Open form to create new record or create if it does not exist

HI guys,

Sorry to bother you with this but i have been head scrathing and searching for hours without success. Here is the problem.

DB with 2 tables, University and AlumniContact a form for each..
University has Primay Key (university ID) autonumber and AlumniContact has one as well (AlumniID) which is a number.
One to One relationship.

Scenario:
Would like to enter a university and then click on my button to open alumni contact in another form. If it exists just to view it and if not a blank form to create it.

Problem
I have triend but cant find a solution. If anyone out there can help I would be eternaly grateful.
Mar 26 '08 #1
1 6132
ADezii
8,834 Expert 8TB
HI guys,

Sorry to bother you with this but i have been head scrathing and searching for hours without success. Here is the problem.

DB with 2 tables, University and AlumniContact a form for each..
University has Primay Key (university ID) autonumber and AlumniContact has one as well (AlumniID) which is a number.
One to One relationship.

Scenario:
Would like to enter a university and then click on my button to open alumni contact in another form. If it exists just to view it and if not a blank form to create it.

Problem
I have triend but cant find a solution. If anyone out there can help I would be eternaly grateful.
Based on the Assumption that the 1 to 1 Relationship is as follows:
Expand|Select|Wrap|Line Numbers
  1. University.[University ID](1) ==> AlumniContact.[AlumniID](MANY)
Expand|Select|Wrap|Line Numbers
  1. Dim blnMatchingRecord As Boolean
  2.  
  3. 'Is there a Matching Alumni Record for the current University Record?
  4. blnMatchingRecord = DCount("*", "AlumniContact", "[AlumniID] = " & Me![University ID]) > 0
  5.  
  6. If blnMatchingRecord = True Then     'don't need true, maintained for clarity
  7.   'assuming Form Name is frmContact
  8.   DoCmd.OpenForm "frmContact", acNormal, , , acFormEdit, acWindowNormal     'Edit Mode
  9. Else        'No Matching Record, so Add one
  10.   If Me.Dirty = True Then Me.Dirty = False      'Save pending Edits
  11.   DoCmd.OpenForm "frmContact", acNormal, , , acFormAdd, acWindowNormal      'Add Mode
  12. End If
Mar 27 '08 #2

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

Similar topics

3
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
20
by: Olav.NET | last post by:
I am a .NET/C++ developer who is supposed to do some work with Access. I do not know much about it except for the DB part. Questions: *1* I am looking for INTENSIVE books to get quickly up to...
8
by: doomx | last post by:
I'm using SQL scripts to create and alter tables in my DB I want to know if it's possible to fill the description(like in the Create table UI) using these scripts. EX: CREATE TABLE(...
1
by: Terry | last post by:
Hello, Has anyone experienced the following problem following an Upsize from Access 97 to SQL 2000 using the MS Upsize Wizard? Or can anyone see what the problem might be. Before Upsize...
13
by: royaltiger | last post by:
I am trying to copy the inventory database in Building Access Applications by John L Viescas but when i try to run the database i get an error in the orders form when i click on the allocate...
4
by: etuncer | last post by:
Hello All, I have Access 2003, and am trying to build a database for my small company. I want to be able to create a word document based on the data entered through a form. the real question is...
12
by: tekctrl | last post by:
Environment; Win2K PC with 1Gb of RAM and plenty of HD space running Access 2002 Issue; Access presents a blank data entry form in the Forms view when the New Record icon is used. However, it...
2
hyperpau
by: hyperpau | last post by:
Before anything else, I am not a very technical expert when it comes to VBA coding. I learned most of what I know by the excellent Access/VBA forum from bytes.com (formerly thescripts.com). Ergo, I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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,...
0
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...

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.