transfer unbound value from form to form (1 Viewer)

antonyx

Arsenal Supporter
Local time
Today, 04:13
Joined
Jan 7, 2005
Messages
556
i know i should know this..

i know how to use link criteria when transfering a key field from one form to the next..

but i am unsure as to how to transfer an unbound value..

on my form frmInvoice i have a button called btnAddInvoice

it opens the form frmNewInvoice

using this at the moment
Code:
Private Sub btnAddInvoice_Click()
On Error GoTo Err_btnAddInvoice_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmNewInvoice"
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_btnAddInvoice_Click:
    Exit Sub

Err_btnAddInvoice_Click:
    MsgBox Err.Description
    Resume Exit_btnAddInvoice_Click
End Sub

on the form frmNewInvoice i have a drop down called cboAccountRef..

i want this drop down to be pre filled with the value from the cboAccount drop down on frmInvoice

what is the simplest way to do this?
 

Brian1960

Brian1960
Local time
Today, 04:13
Joined
Aug 13, 2004
Messages
141
Open New Form

Enter this into the onClick even of the btnAddInvoice Button.

Code:
DoCmd.OpenForm "frmNewInvoice", acNormal
Forms("frmNewInvoice").cboAccountRef= Me.cboAccount

You could have the form open but hidden , acHidden
Then set it it to visible when filled but frankly I never bother as users perfer to see it open.
 

ShaneMan

Registered User.
Local time
Yesterday, 20:13
Joined
May 9, 2005
Messages
1,224
Hey antonyx,

Depending on how cboAccount is set up, but if the value from cboAccountRef is in cboAccount and if a new record is being created in frmNewInvoice then you could use cboAccount DefaultValue to make it equal what the value of cboAccountRef is on frmInvoice (this is assuming frmInvoice stays open when frmNewInvoice is opened) so you could put in the DefaultValue of cboAccount you could put:

=Forms![frmInvoice]![cboAccountRef]

This will use the first column of each cboBox to reference if you need another column to reference by then you will need to add: .Column(ColumnNumberHere) to the end of [cboAccountRef]. Keep in mind that Access starts counting columns at 0 so the second column is actually referenced as: .Column(1)

HTH,
Shane
 

antonyx

Arsenal Supporter
Local time
Today, 04:13
Joined
Jan 7, 2005
Messages
556
thank you both.. thats pretty much everythin i needed to know..
 

Users who are viewing this thread

Top Bottom