Store printer names in variables

  • Thread starter Thread starter RipperT
  • Start date Start date
R

RipperT

(Access2000) I have a form with two unbound combo boxes. Their row source is
set to
GetPrinters. I would like the user to be able to choose a printer from
either of these cbo boxes and have that printer name stored into a
'global' variable to be used in other forms' code throughout the DB. How can
I
store these printer names without using a table?

Many thanx,

Ripper
 
In the after update event of the combo box, simply assign the printer value

gblstrPrinter = me.MyCombo

note that any un-trapped error in the application will re-set his value. So,
this means either you better have error trapping everywhere, or just simply
use a mde (un-trapped errors in a mde don't re-set your variables).

Since you application is split (we hope it is), then you could also have a
table and field that stores the users setting, and this would be in the
front end part...so, each users setting would be respected...

Also, note that a2002 and later has a printer object...but, a2000 does not
(so Dave's H posted code will not work in a2000).
 
How can I quickly tell if the value was stored in the variable? As far as I
can tell, it isn't there. I have the following code behind the form.

Private Sub Form_Load()
Me.Combo0.RowSource = GetPrinters
Me.Combo0 = glblstrPrinterOne
Me.Combo1.RowSource = GetPrinters
Me.Combo1 = glblstrPrinterTwo
End Sub

Private Sub Combo0_AfterUpdate()
glblstrPrinterOne = Me.Combo0
End Sub

Private Sub Combo1_AfterUpdate()
glblstrPrinterTwo = Me.Combo1
End Sub

Each time I close and reopen the form, the cboboxes are empty. Wouldn't the
above code retain the values in the cboBoxes?
Also, how does one simply use a mde (if they have a split mdb)?

Rip
 

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

Back
Top