Setting a combo box value

G

GLT

Hi,

I am opening a form with the docmd.openform, and once the form opens I would
like to set the value of a combo box on that form automatically, based on a
record that was slected (double clicked) on the previous form.

The code below works and will open the form with the combox box value
completed, but for some reason when any of the first 6 records on the
original form are double clicked, the second form will open and the combo box
will be blank.

I have put a msgbox in to check the Me!Server values and they are all fine.
I have also checked the combobox values to make sure they exists there too
amd they do. Can anyone advise what might be causing this?

Cheers,
GLT.



MsgBox Me!Server
DoCmd.OpenForm "frm01_WServices"
Forms.frm01_WServices.cmbServer.Value = Me!Server
 
J

Jeff Boyce

I'm not familiar enough with your situation to tell, so take this as merely
a question...

If you've already selected a record on a form, what does having a second
form open (with a preloaded combobox) allow you to do (that you
couldn't/don't already do on the first form)?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
G

GLT

Hi Jeff,

Thanks for your reply - the 1st form contains a list of servers and errors
that occured on them.

Second form is a utility that you can open, select a server and it connects
to an individual server and extracts some info.

I am just trying to make a short cut, so that when you double click on a
particular record in the first form, the second form auto populates the
server field and executes the code to go to the server and fetch the info.

I do have a button on the first form that opens the second form, and on the
second form you can scroll through a list of servers, and in the combo box
and select your choice, and then click the update button. This works file,
but is tedious if you want to repeat thsi process for lots of servers....

It would be nice to have the double click feature to save mouse clicks and
scrolls :)

Cheers,
Geoff.
 
J

Jeff Boyce

Geoff

So, your second form has code that goes to a selected server and fetches
information.

Again, why couldn't your first form do this? Can you add the code from
form2 to form1 and do this without benefit of form2?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
J

Jeff Boyce

.... and to follow up on your response, is there anything different about
"the first 6 records"?

The notion of order is not something Access tables have ... to get "the
first 6", your form must impose some kind of order. What is that?

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
G

GLT

Hi Jeff,

Thanks for your reply - re: your second last post, the first form is just a
datasheet showing a summary of Servers and errors. The second form is a more
complicated form with lots of details regarding any servers you pick in the
combo box.

I guess to compare with the Northwind BD, imagine if you had a list of oders
that were placed for a particular week in data sheet form, and when you
double clicked an order, it opened up another form that showed you the full
company details and lots of other info about that company. Of course you
could have a button on form 1 that opens form 2, and then select the company
via a combo box, but if the user had to check 50 of those records, and the
combo box has a lot of choices, then double clicking and setting the new
form to the record you double clicked would be much faster. Also, most of
the time there will be no need to open form 2, so to try and include all that
extra info in form - I can't see how it would work...

In my case, the only thing common between form1 and form2, is the server
names. Once you select a server name in form2, it goes out to that server,
collects information and then populates a table locally, so there is no
related records between the two forms. I already have the button which opens
form 2 and it all works OK, just be nice to have access select the record
from form 1 and process the server selected when form 2 opens up.

re second post: from what I can see, there is no difference between value
the (Forms.frm01_WServices.cmbServer.Value) and the (Me!Server) value, thats
why I put the message box there so I could see it (ie. any value that
me!server displays via a message box, also exists in the combo box on form
2)... ill check on how the form odering works, but I would of thought that if
you were setting the .value of a combo box, record ordering would not be
taken into account?

I appreciate your help...

Cheers,
Geoff.
 
G

GLT

Ok I figured this one out...

When I created the Combo box, and selected get values from a table, I
selected the server field, but another field was selected as well (asset
no.). Most of the asset number fields had the same entry as the server
field, except a few. I have deleted the asset field and only have the combo
box linking back to the server field... now it works perfectly.

I only need to now get the form#2 to execute its update button from form #1...
 
J

Jeff Boyce

Geoff

I suppose one approach (not pretty, but possible) would be to pass an
OpenArg value to form2 when you start at form1.

Your form2 could then:
1) test to see if it has a OpenArg value
2) ensure it has a value in the combobox
3) click its own button

Steps 2 & 3 would only fire if OpenArgs were properly valued.

Good luck!

Regards

Jeff Boyce
Microsoft Access MVP

--
Disclaimer: This author may have received products and services mentioned
in this post. Mention and/or description of a product or service herein
does not constitute endorsement thereof.

Any code or pseudocode included in this post is offered "as is", with no
guarantee as to suitability.

You can thank the FTC of the USA for making this disclaimer
possible/necessary.
 
G

GLT

Hi Jeff,

I changed the button on form #2's sub to public, and then performed this
command:

Forms!frm01_Services.cmdGetServicesData_Click

Works a treat (thanks for yours and Dirk's assistance with this)...

Cheers,
GLT.
 

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