Combination box default

G

Guest

Hi,
On form opening, I want to populate a form combination box from a table
where the user has selected one recordset as the default.

The way the default is chosen is by going to frmProvider and pushing a
command button to chose that record as default, but I need help with how to
do that. Right now I have:

'Makes this provider the default choice when the pilot data form is opened
Private Sub cmdDefault_Click()
Dim rsProv As Recordset
Set rsProv = Me.Recordset
End Sub

Then on the other form, on open property, should I have something like:

'Opens form pilot to new record & loads default provider
Private Sub Form_Open(Cancel As Integer)
DoCmd.GoToRecord , , acNewRec
Me.cboProv.rsProv
End Sub

Thank you,
Karl
 
G

Guest

Try this
On the declaration of the form declare a string
Dim MySQL as String
===========================================
On the OnClick event write
MySQL = Me.RecordSource
===========================================
On the OpenForm command line pass the MySQL with the open Args
docmd.OpenForm "FormName",,,,,,MySQL
===========================================
On the OnLoad event of the form, write
Me.cboProv.RowSource = Me.OpenArgs
===========================================
I didn't try it, but I hope it works out
 
G

Guest

Hi Ofer,
thank you--I didn't clarify that the "Make default" cmd button is on a
Provider form using tblProvider as a datasource.

I want to populate the combo box on "frmPilot," which mostly uses data from
a different table. I want that frmPilot to open to a new record, which it
currently does, but I want the cboProv box loaded with the default selection
from the other form, frmProv.
Thanks again!
Karl
 
G

Guest

In that case

On the OpenForm command line pass the ComboValue with the open Args
docmd.OpenForm "FormName",,,,,,Me.ComboName
===========================================
On the OnOpen event of the form, write
Me.cboProv.DefaultValue = Me.OpenArgs
 
G

Guest

Hi Ofer,
Thanks for hanging in there with me. I'm not quite there yet.
When you say, "on the OpenForm command line, I'm not sure if you're talking
about the "On Open" command line, or if you mean to write the cocmd.openForm,
etc immediately after setting MySQL to Me.RecordSource, in the next line of
VB code?

I tried putting the code you mentioned in the On Load area, and it cued me
to use SQL "SELECT Tables.ect.

A totally different approach, which wouldn't require passing arguments
between forms, may be to have a check box on the frmPilot where the checkbox
checked declares that selection of the combobox, cboProv, as the default
provider to be loaded with every form entry.

What do you think?
Thank you,
Karl
 

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

Similar Threads


Top