a variable in a method

Rudi GOUSSEY

New Member
Joined
Jan 8, 2004
Messages
32
Is it possible to use a variable in a method

Private Sub cmbFles_AfterUpdate()
txtItem.SetFocus
retvalItem.Value = "Bottle"
DoCmd.OpenForm "Failure Bottle"
End Sub

I would like to use an variable in code (just an example to illustrate) above as you see below, but this don't work. Maybe it is not possible

Private Sub cmbFles_AfterUpdate()
dim retval as string
retval = txtItem
retval.SetFocus
retval.Value = "Bottle"
DoCmd.OpenForm "Failure Bottle"
End Sub

Thx in advance for the help
Rudi
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
Is it possible to use a variable in a method
Yes

But not in the way you have in the second piece of code posted.

What do you actually want to do?
 
Upvote 0
I'll try to explain

Suppose i have on a form

two comboboxes :
cmbCombo1 with items : bottle, cap, label
cmbCombo2 with items : red, blue, white

6 checkboxes
chkbottle
chkcap
chklabel
chkred
chkblue
chkwhite


I also have a table tblData with fields (boolean) :
bottlered
bottleblue
bottlewhite
capred
capblue
and so on

choosing bottle in cmbCombo1 makes the checkbox bottle on the form true
and choosing red in cmbCombo2 makes the checkbox red on the form true

If checkbox bottle and red are true the fieldvalue bottlered in the table shoud be true
If checkbox bottle and blue are true the fieldvalue bottlered should be false and bottleblue true

the same way for cap and label


If explanation unclear please let me know

Thx in advance
Rudi
 
Upvote 0

Forum statistics

Threads
1,221,829
Messages
6,162,232
Members
451,756
Latest member
tommyw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top