Can you have an ID automatically entered when form is called up?

B

Bayou BoB

I have a main Client form, where users enter the basic information for
any client admitted to our institution. On this form, I have a button
that opens a second form that has client family contact information,
and it is set to show specific records based on "ClientID". However,
if there is no record already entered for that particular client, the
"ClientID" box comes up empty in the now opened familycontact form. To
add a record, the user must enter the ClientID number manually, in
order to make the new record match up to that client for future
retrieval. I would like that ClientID to come up automatically whether
there is a record or not. Is there a way that access can put the
ClientID in automatically when the form is loaded, when there hasn't
been a manually entered record added yet? The rest of the fields in
the record can stay blank if need be, that's not a concern. Or is
there no way around having to manually enter a clientID when there is
no record already entered? If there is a way, could you explain how to
accomplish this? Many thanks, it's one of my last steps to completion.

Kevin

Relationship is one to many here, as opposed to one to one due to
ClientID not being the primary key in the familycontact table.
(relationship built by connecting ClientID on both tables).

Table structures are as such:

[clienttbl]
ClientID (autonumber)(Primary Key)
LastName
FirstName
DOB
DOA
AdmitFrom
AdmitFor
SIN
BirthCert
A few other things


[familycontacttbl] -No Primary Key on this table
ClientID (number)
Name
Relationship
Address1
Address2
City
Province
Country
PCode
Phone
Fax

(to recap, If I'm looking at a client (eg. Aaron Mills, ClientID 501,
rest of info blah blah)....and I hit the button "Family
Contacts"....the form should load, and if there is no information
already entered for this individual, the now loaded form should at
least have a "501" in the ClientID box....rather than the user having
to remember or go back and figure out what the ClientID is, in order
to type it manually into the new form.)

THANK YOU!!!!!
 
J

John Vinson

I have a main Client form, where users enter the basic information for
any client admitted to our institution. On this form, I have a button
that opens a second form that has client family contact information,
and it is set to show specific records based on "ClientID".

Why not make the second form a Subform of the first, using ClientID as
the master/child link field? This will ensure that the link is
maintained for existing and new records.

If you need the screen real estate, you can put a Tab control on the
form; put all the basic client information on the first tab page and
put the subform on a second one.
 
X

Xiphias

I've had the same problem and I solved that like this:

-----------------------------------------------------------------


Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Repair Query" 'replace R.Q for the name of your second form

stLinkCriteria = "[RMA nr]=" & "'" & Me![RMA nr] & "'" ' Change RMA nr
to the name of the field you gave as matching field in form 1 and 2
If Me.NewRecord Then
' when you made the button to open 2nd form

DoCmd.OpenForm "Repair Query", , , , acFormAdd ' 'replace R.Q for the name
of your second form
Forms![Repair Query]![ClientID] = [Forms]![Name of your main
form].Form![ClientID]

Else
DoCmd.OpenForm stDocName, , , stLinkCriteria
End If



Exit_Form__DblClick:
Exit Sub

Err_Form__DblClick:
MsgBox Err.Description
Resume Exit_Form__DblClick

End Sub
-----------------------------------------------------------------
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top