Subform Dataentry Problem

X

xgamer

Hi, the summary of my problem is the following: I'm having trouble opening a
form, with its subform having a new entry already created and data from the
main form put in it

Let me give you more table details:

tblClient: Client# and data, tblOrder: Order# and data , tblOrderProduct:
Products associated with that order

Form Details:

Main form frmBilling: Contains client information when it opens, it got to
display previously chosen client's data

frmBilling's Subform frmOrder: When opened, automatically add a new order
entry with the Client # in tblOrder.NumClient and a default order# when
frmBilling opens

frmOrder's Subform frmOrderItem: Allows to manually add one or more product
in that order with the frmOrderItem.NumOrder being the parent's form order
number


The way it currently works: frmBilling is opened after a search for a client
in another form. I pass the NumClient as openargs, and in the form load I
filter the frmBilling so that I have the correct client info displayed and
requery the subform. In frmOrder I assigned a function that returns the next
order number in the DefaultValue property if my NumOrder textbox.

The problem: When the frmBilling is opened, the subformOrder.txtNumOrder
displays the good order # but a new entry wasnt yet created (as if the value
is in txtNumOrder rather than in the NumOrder table field. Then if I try to
add a new product in the order, the subfrmOrderItem.NumOrder will not contain
the order# because no new order exist.

If I enter some data in the order before adding an item, a new order entry
is created and from now on, new items contains the order#

What I need: To be able to open the frmBilling displaying only one client,
no navigation or adding clients. frmOrder must have a new entry linked to my
client and with the new order# being provided by me thru a function call.
frmOrderItem works ok only if a new order exist so I believe there are no
problems there.

Thank you very much for your help!
 
S

Steve Schapel

Xgamer,

Have you got the Link Child Fields and Link Master Fields properties of
the frmOrder subform set to NumClient and Client# respectively? I think
one approach would be like this...
1. Set the Data Entrry property of the frmOrder form to Yes, so it
automatically opens at a new record.
2. Use SetFocus on the Load event of the frmBilling form to move the
focus to the frmOrder subform.
3. Apply your code to set the value of the Order# field.
4. Use DoCmd.RunCommand acCmdSaveRecord to save the new Order record
before moving to the frmOrderItems subform.

FWIW, I would generally not model forms like this. I would not have a
form based on the Client table implicated in the process of Order entry.
I would have the Order form as the main form, and a combobox on the
Order form for the entry of the Client that the Order pertains to. The
data you end up with is the same, but the process of managing the orders
is simpler. If you need to see Client details, you can have a little
command button on the Orders form to open a Client form at the related
Client record.

By the way, on a complete tangent, it is not a good idea to use a # as
part of the name of a field or control.
 

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