How do i get the value from a comboxbox and link it to print.

MelonFuel

Registered User.
Local time
Today, 04:38
Joined
Jun 15, 2012
Messages
31
Hi

Im in a spot of bother.

What i need to be able to do is write vba to find the value inside the comboxbox and then either:-

1. Run a macro with the same value that is in the combobox

Or

2. Run a set of reports and print them off but are linked to the combobox value.

The combobox name is ODTyper
The combobox control source is ODType which is a field in TblType
The combobox row source is SELECT [TblType].Model FROM TblType;
The value inside the combobox are in the format of TE4700
The name of the macros are in the format of TE4700
The Main form is called FrmOrderDatabase.

Plus somehow i need to get the value of the combobox and link it to print off the correct reports.

Thanks MelonFuel
 
Code:
Me.YourCombName.Text
Will return the text that is displayed in your Combo Box.
 
Hi John Big Booty

The code has an error saying invalid use of property?

This is the code i have been given to work on by pere de chipstick.

Code:
Dim intModelID as Long
Dim intSerialNo  as String

intModelID = NZ(Me.ODtyper,0)
if intModelID = 0 then
    MsgBox "You must enter a model type", vbexclamation, "No ModelD"
    Exit Sub
End if 

intSerialNo = NZ(Me.[SERIAL NUMBER],"")
if intModelID = "" then
    MsgBox "You must enter a Serial Number", vbexclamation, "No Serial Number"
    Exit Sub
End if 
...

But i cant get it to do what i want it to

Any help would be great

Thanks MelonFuel
 
Nothing is highlighted it says that there is something wrong with the .text part
 
Hi Pat

This is the code i have now.

Code:
If NZ(Me.ODTyper,"") <>"" then DoCmd.RunMacro Me.ODTyper

But it gives me a parameter on every report if there a way to remove it.

Thanks MelonFuel
 

Attachments

  • error parameter.PNG
    error parameter.PNG
    7.3 KB · Views: 173
Can you show all of the code for the event you are using?

You have shown only a portion of the code.
 
Heres the full code im using

Code:
Private Sub btnprint_Click()

If Nz(Me.ODType, "") <> "" Then Docmd.RunMacro Me.ODType

End Sub
 

Users who are viewing this thread

Back
Top Bottom