VB does not start

  • Thread starter Cipher via AccessMonster.com
  • Start date
C

Cipher via AccessMonster.com

I have an Access Form with VBA Code attached to an "On Change" on a ComboBox.
If I run this Form from the database I get " The expression "On Change" you
entered as the event property setting produced the following error: return
without GoSub. If I open the VB Editor it runs perfectly.

I obviously have a setting wrong somewhere...please help, thanks.
 
L

Linq Adams via AccessMonster.com

If you want help figuring out what's wrong with your code, we really need to
***see*** your code!

Also, this type of event should be in the combobox AfterUpdate event, not the
OnChange event. The OnChange event will fire if your user types a single
character into the combobox (as in using the AutoExpand feature) and your
code will be executed using the value that resides at that point, usually
Null. This may cause an error and undoubtedly won't give you the results you
want, which presumably based on a selection from the combobox.
 
C

Cipher via AccessMonster.com

Here is a code fragment that isues the call:

If Loads_Check = True Then
RunCommand (acCmdPrint)
Comments = ""
Else: Beep
Comments = "NO Records to PRINT"
End If

The reason I used the "Private Sub ComboMonth_Change()" is because the
ComboBox is pre-filled with the Months of the Year so that the user can
choose the month that the report should run. The code fragment shows the call
to RunCommand(acCmdPrint). Unfortunatly, this invokes the User Prompt for the
Printer Dialog Box which I do not want. I would prefer the system to just
print to the default printer for each Report automatically generated by the
VBA Code.

For now, I just need to know why it is necessary for the VB Editor to be open
before the Form will execute. It is as thogh the VBA COde is not available to
the Access Form for some reason. What would cause this?
 

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

Top