How to open form if record doesn't exist?

hmoritz72

New member
Local time
Today, 11:54
Joined
Nov 17, 2008
Messages
8
This is probably very easy and my mind is tired, but I need help ASAP on this issue... it is driving me CRAZY! :confused:

Here is my issue:

I have a client form with clientID (and other pertinent information). I want to open an employee information form that will show only employees for that client. (It opens frmEmployeeData by clientID and the form has a subform to show each Employees information).

My problem is that I get an error if there is not an existing record already (ie... tblEmployeeData does not have a record YET). How can I either create a record and THEN open the form or open the form to show the client information with a record waiting to be filled in?

My table names: tblClient (clientID) and tblEmployeeData (clientID) are the linked fields. Is there a way (in the background) to create a field in each related table each time a new record is created?

What am I forgetting or missing here????

Thanks for any suggestions,
hmoritz72 (mother of 3, part time Access 2007 programmer) :eek:
 
Go to the form's properties and check the "Allow Additions" setting. It should be set to "Yes".
 
"Allow Additions" is already set to yes. I think I might not be explaining it well enough.

Here is my code:

If Not IsNull(Me.ClientID.Value) Then
' Update Client Name
Me!Company = DLookup("CompanyName", "tblClient", strFilter)
Else
Me.ClientID = frmClientInfo.ClientID

Me!Company = DLookup("CompanyName", "tblClient", strFilter)
End If

I get an error of "Object Required" for this code. Any ideas what is wrong?

I am trying to open a form to a record that doesn't already exist. I am trying to sort of create a new record on the fly.
 
just trap the error, and ignore it

If Not IsNull(Me.ClientID.Value) Then

this is the problem - the trouble is, your recordset probably doesnt allow you to add items. with an empty recordset, and a non-updateable recordset, trying to do this sort of thing still generates a run time error

the values are undefined, not null

you might be able to do

if clientid is nothing
.... but generally you need to error trap it - and the error is a massive number in the 2Billion range from memory
 

Users who are viewing this thread

Back
Top Bottom