Add Data

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
I have a table called Customer Details and a form that is used to view these
details via a query.
For Example.
Customer Name J Doe, Account Num 1111
When opening the form there are other buttons on the form that open other
forms again via a query with the query parameter being taken directly from
the account number field on the form.

However, When the customer details form is opened in ADD mode, (to add a new
record) the system generates a a/c number, the user enters the data and saves
the data. However when one clicking the button to open one of the other
assoicated forms that form opens in add mode too, instead of populating the
account number field already.

I hope this makes sense.

Any help appreciated
 
Are you sure that the new customer record is saved before opening the other
form? Try explicitly saving the record before opening the other form. It
won't matter if this is not a new record:

RunCommand acCmdSaveRecord
DoCmd.OpenForm "SomeOtherForm"

I suspect that's not the problem, however, but simply that no new record yet
exists in the other form's underlying table. The way I'd handle this sort of
situation is to pass the Account Number to the other form via the OpenArgs
mechanism:

RunCommand acCmdSaveRecord
DoCmd.OpenForm "SomeOtherForm", OpenArgs:= Me.[Account Num]

Then in the other form's Open event procedure set the DefaultValue property
of the Account Number to the value passed to it, testing for Null in case the
form is opened independently of the first form:

If Not IsNull(Me.OpenArgs) Then
Me.[Account Num].DefaultValue = """" & Me.OpenArgs & """"
End If

Note that the DefaultValue property is a string expression regardless of the
data type involved, so is wrapped in quotes. Again it doesn't matter if the
record is not a new one as the Defaultvalue property only comes into play
when a new record is being added, so has no effect on existing records.
 

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

Back
Top