Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subform DataEntry Problem 1

Status
Not open for further replies.

mastermeo

Programmer
Joined
Aug 29, 2005
Messages
2
Location
CA
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!
 
Mastermeo,

Have you looked at the "Order Entry" example database in microsoft Access. It sounds like the same program with the exception of your function: "assigned a function that returns the next order number in the DefaultValue property if my NumOrder textbox.

Unless I am mistaken. This sounds like a modified version of the "Order Entry" example.

Maybe you can look at it and see if it helps. I am assuming your table relationship and queries behind your frmBilling and frmBilling's Subform frmOrder are similar.


 
How are ya mastermeo . . . . .

Your dealing with two problems:
[ol][li]A form with nested subforms [blue]opens from the inner most subform out to the mainform.[/blue] So the mainform is actually the last to load.[/li]
[li]A new record is not instantiated until its in [blue]Edit Mode[/blue] (depicted by the pencil icon). This is usually triggered by typing in the record. Your problem here is that [blue]writing to DefaultValues does not trigger Edit Mode![/blue]
There's an [blue]Dirty property[/blue] that can be used to test edit mode of a record. It can also be used to set edit mode and save a record.[/li][/ol]
The quickest fix I can think of is as follows:
[ol][li][blue]Remove the requery[/blue] of frmOrder[/li]
[li]At the end of the [blue]Load[/blue] event for frmOrder (this is last code in the event), copy paste the following:
Code:
[blue]   DoCmd.RunCommand acCmdRecordsGoToNew
   Me.Dirty = True[/blue]
[/li][/ol]
[purple]Give it a whirl & let me know . . .[/purple]

Calvin.gif
See Ya! . . . . . .
 
How can I take a look at the Order Entry example database in microsoft Access?

"1. A form with nested subforms opens from the inner most subform out to the mainform. So the mainform is actually the last to load."

Very nice to know :)

"2. A new record is not instantiated until its in Edit Mode (depicted by the pencil icon). This is usually triggered by typing in the record. Your problem here is that writing to DefaultValues does not trigger Edit Mode!"

Thats what I figured out.

Here's how I fixed it if it matters to anyone:

The big issue is relying on DataEntry mode for subforms. It seems to work perfectly only if the main form is also in dataentry mode.

Since there was no messing around with the client info, I removed the frmBilling and made client info a unbound subform of frmOrder. In the "OnLoad" event of frmOrder, I manually populate it using the frmOrder.subform.form.recordsource property, and I put Me.NoClient = Me.OpenArgs and
Me.NumOrder = GetNextNumOrder()
that way client info is displayed to the user. Both frmOrder and frmOrderItem are in DataEntry mode so when I enter values in NumOrder and NoClient, a new record is effectively created.

I managed to do this since I posted right before lunch and didnt expect quick answers. Thank you very much.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top