473,396 Members | 1,891 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,396 software developers and data experts.

Linking records in two tables using a command button

Hi,

I am creating a database in which users will enter details for one client (record) in several tables via several associated forms. I would like to have a button on each form that takes the user directly to the next form. If it is a new record I want the form to load with a blank form but pulling across the ClientID (unique identifier) but if a record already exists then link by the ClientID. So if going from frmInitial to frmFamily some code that says if new record then ClientID in frmFamily will equal ClientID in frmInitial but if revisiting the record (i.e. data already input but being edited or viewed) the correct record as per ClientID appears.

I already have the following in the Where Condition section of a macro [Forms]![frmInitial]![PatientID]=[tblFamily]![PatientID] and an OnLoad expression to carry over ClientID if a new record but this doesn't seem to work for the command button - any ideas??

Help much appreciated
Lucie
Jul 30 '09 #1
2 2130
missinglinq
3,532 Expert 2GB
In The calling form

Expand|Select|Wrap|Line Numbers
  1. Private Sub Go2FormB_Click()
  2. If Not IsNull(Me.OrderID) Then
  3.   DoCmd.OpenForm "TableB", , , , , , Me.OrderID
  4.  Else
  5.   MsgBox "A Visit ID Must Be Entered First!"
  6.  End If
  7. End Sub
  8.  
In the called form

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.  
  3. If Not IsNull(Me.OpenArgs) Then
  4.  
  5.  Set rst = Me.RecordsetClone
  6.  
  7.  rst.FindFirst "[OrderID] = '" & Me.OpenArgs & "'"
  8.  
  9.   If Not rst.NoMatch Then
  10.       Me.Bookmark = rst.Bookmark
  11.    Else
  12.     DoCmd.GoToRecord , , acNewRec
  13.     Me.OrderID = Me.OpenArgs
  14.    End If
  15.  
  16. rst.Close
  17. Set rst = Nothing
  18. End If
  19.  
  20. End Sub
  21.  
The above code assumes that OrderID is Text. If it is Numeric instead, replace

rst.FindFirst "[OrderID] = '" & Me.OpenArgs & "'"

with

rst.FindFirst "[OrderID] = " & Me.OpenArgs


Linq ;0)>
Jul 30 '09 #2
Great, that works - for the second part I already had an OnLoad event to pull in a few other fields as follows:

If Me.NewRecord Then
Me.ClientID = [Forms]![frmClientDetails].[ClientID]
Me.CHI = [Forms]![frmClientDetails].[CHI]
Me.ClientForename = [Forms]![frmClientDetails].[ClientForename]
Me.ClientSurname = [Forms]![frmClientDetails].[ClientSurname]
End If

How can I incorporate that into the Load event you describe?
Jul 30 '09 #3

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

Similar topics

9
by: Catherine Jo Morgan | last post by:
Can I set it up so that a certain combination of fields can't contain the same entries, on another record? e.g. a combination of FirstName/LastName/address? Or FirstName/LastName/phone? Or...
14
by: diskoduro | last post by:
Hi!! Years ago I built a database to control the production of a little factory. The users wanted to work in a Windows Net workgroup so I created an mdb with all the tables and data an after...
2
by: Salad | last post by:
OS = WinXP & Win98. Access = A97 & AXP Q1) Where can I find the VFP ODBC driver at Microsoft. I have been working developing an app in Access that will link to some DOS FoxPro tables. I...
0
by: Jason | last post by:
I would like to be able to place a command button on a primary (parent) form that opens up a subform. I want to use this subform to search for or limit the recordset of data in the primary form. ...
1
by: Daveyk0 | last post by:
Hello there, I have a front end database that I have recently made very many changes to to allow off-line use. I keep copies of the databases on my hard drive and link to them rather than the...
2
by: TheTamdino | last post by:
One of the things that is common between most genealogy databases is that they will have one screen were you log all the information for a given person and then (maybe) have a link to a source...
11
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my...
4
by: JPG4 | last post by:
I have tried just about everything that I can think of, so now I turn to you all for help! I have created a form (titled "OAG") with an unbound textbox titled "DOW". I also have a Query that I...
5
by: luciegiles | last post by:
I have 2 tables, tblParticipantDetails and tblPreCourseQ - both have ParticipantID in them and this links the tables in relationships. ParticipantID is the primary key (and an autonumber) in...
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: 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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
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,...

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.