running a macro from code?

F

fishqqq

is it possible to run a macro from code?

i have some code which works perfectly and after it runs i'd like to
run a macro right after.

the code is as follows:

Private Sub Combo235_AfterUpdate()
Me.Notes__internal_tracking_ = Now() & " - " & Forms![Shipment Tracking
II]![fCurrentUser]![USER CODE] & " - " & "*** " & [Combo235] & " ***" &
" - " & "" & vbCrLf & Me.Notes__internal_tracking_

Me.Notes__internal_tracking_.SetFocus
Me.Notes__internal_tracking_.SelStart = 27

End Sub

and the macro i wish to run (if possible) is : Shipment Tracking.update
status

is there a way to join the two?
(btw - it would be very difficult for me to put into code what the
macro is doing.it's a lot simpler for me to create the macro and
trigger it somehow)

any suggestions are appreciated.
- Steve
 
R

Roger Carlson

There are VERY few things tha can be done in macros that cannot be done in
code. In most cases, you can save the macro as VB module with no problem.
Right click on the macro and choose Save As... In the save as box, choose
Module in the AS dropdown box. That's about it.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
F

fredg

is it possible to run a macro from code?

i have some code which works perfectly and after it runs i'd like to
run a macro right after.

the code is as follows:

Private Sub Combo235_AfterUpdate()
Me.Notes__internal_tracking_ = Now() & " - " & Forms![Shipment Tracking
II]![fCurrentUser]![USER CODE] & " - " & "*** " & [Combo235] & " ***" &
" - " & "" & vbCrLf & Me.Notes__internal_tracking_

Me.Notes__internal_tracking_.SetFocus
Me.Notes__internal_tracking_.SelStart = 27

End Sub

and the macro i wish to run (if possible) is : Shipment Tracking.update
status

is there a way to join the two?
(btw - it would be very difficult for me to put into code what the
macro is doing.it's a lot simpler for me to create the macro and
trigger it somehow)

any suggestions are appreciated.
- Steve

Just add to your code where you want the macro to run:
DoCmd.RunMacro "MacroName"

See VBA help.
 
R

Rob Oldfield

True. It will do. But Roger's suggestion is better. Macros are (mostly)
just a hangover going back to Access 1.1. They're inflexible, awful to
debug and completely unclear when you come back to them 6 months down the
road. Converting to VBA (and then looking through the code to learn what is
going on) is much better.
 

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