OpenForm Problem - populating Opened form

G

Guest

I have a "purchase order" form with a combo box named "po". This form has a
main form and two subforms. The combo box on the main form has a list of
purchase order numbers. I select a purchase order, and it populates the
following text boxes on the main form:
Purchase order
Supplier
Order Data
Contact
It also populates the two subforms with purchased items, based on the PO
number that was selected (the source is the "PO number" table).

Here's the problem:
I have another form which contains a subform. This subform is a datasheet
list of records - one record for each PO number from the PO number table. I
click on the PO field from a selected record to open the "purchase order"
form. I want the "purchase order" form to open at the selected PO number
(just as if I opened "purchase order" form manually and selected the PO
number from the combo box. Here's what I have in the subform:

Private Sub PO_1_DblClick(Cancel As Integer)
strDocName = "purchase order"
DoCmd.OpenForm strDocName, , , "po = " & PO_1
End Sub

The "purchase order" form opens fine. The Order date is correct from the
"po number" table. None of the other fields get filled out. The combo box
is empty and the "purchase order" form says "filtered" at the bottom.
I know it's grabbing the correct record, because the "podate" text field in
the form is correct for that record. How do I get the other fields to fill
in. Somehow- I think I need to get the PO combobox filled in with the
correct value because this is the combo box that drives all of the text
fileds and the two subforms.

Background on the "Purchase Order" form:

The "po" combobox looks like this:
Private Sub po_AfterUpdate()

Me!supplierID = Me![po].Column(1)
Me!suppliername = Me![po].Column(2)
Me!podate = Me![po].Column(3) -> THIS IS THE ONLY TEXT BOX THAT GETS
FILLED IN PORPERLY WITH THE Docmd.OpenForm

Me!reqd_date = Me![po].Column(4)
Me!suppliercontact = Me![po].Column(6)

End Sub
 
A

AccessVandal via AccessMonster.com

Hi Bill,

Try using the Dot instead of Bang. Like....

Private Sub po_AfterUpdate()
Me.supplierID = Me![po].Column(1)
Me.suppliername = Me![po].Column(2)
Me.podate = Me![po].Column(3) ' -> THIS IS THE ONLY TEXT BOX THAT GETS
'FILLED IN PORPERLY WITH THE Docmd.OpenForm
Me.reqd_date = Me![po].Column(4)
Me.suppliercontact = Me![po].Column(6)
End Sub

Also, can you provide the Form's RecordSource and the Combo Source?
 
G

Guest

Thank you very much for the reply- it's really got me puzzled.

I revised the event on the "Purchase Order" form's combo box per your
suggestion as follows:

Private Sub po_AfterUpdate()
Me.supplierID = Me![po].Column(1)
Me.suppliername = Me![po].Column(2)
Me.podate = Me![po].Column(3)
Me.reqd_date = Me![po].Column(4)
Me.suppliercontact = Me![po].Column(6)
Me.supplierphone = Me![po].Column(11)
Me.supplierfax = Me![po].Column(12)
End Sub

This did not fix it. It still only fills in the "podate" text box of the
"purchase order" form, none of the other text boxes get filled in.

Here's more info on the "purchase order" form that I'm trying to fill in
with the OpenForm:

RowSource for the "po" combo box on the "purchase order" form:

SELECT [PO Numbers].PO, [PO Numbers].supplierID, [PO Numbers].suppliername,
[PO Numbers].date, [PO Numbers].[reqd date], Vendors.[supplier name],
Vendors.[Contact name], Vendors.address, Vendors.city, Vendors.state,
Vendors.[zip code], Vendors.[phone number], Vendors.[fax number],
Vendors.terms FROM Vendors INNER JOIN [PO Numbers] ON Vendors.[Supplier
ID]=[PO Numbers].supplierID ORDER BY [PO Numbers].PO DESC;

("PO Numbers" is the table containing a record for each PO. Each PO record
is then linked to a "purchased materials" table. The PO Numbers table
contains the fields: PO, supplierID, suppliername, date, reqd date, contact,
creditcard)

Record source for the "Purchase order" form is: "PO Numbers" table

The two subforms in the "Purchase order" form are linked as follows:
master field: po
child field: po

(po is the field with the PO number and the PO is what drvies this form.)
 
G

Guest

As I look through examples of docmd.openform, I don't see any examples that
open a form with criteria for a combobox like I have. They all have criteria
for text boxes. Maybe it's not possible. Afterall, it's the combobox
selection that drives the event to fill in the other fields.
 
G

Guest

I figured it out-
The "purchase order" form that was the popup form, all of the fields were
"unbound". That worked fine when using the form as usual, but not when
opened vi docmd.openform. Once I selected a control source for the PO
combobox each textbox- it worked.
 

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