When I have code [usually a Function] in a module that I want to run from a Macro, I create a new Macro & choose the 'Run Code' option.
That Sub is not a Macro - so I wouldn't expect it to show up in the Run Macro dialog box.
I have never tried running a subroutine using the 'Run code' option.
Hope this helps.
Hi -
As Robeen has pointed out, a Sub is not a macro, so you won't see it in macro lists. But what are you trying to do with this sub, specifically, what is Obligor_ID? Is there more code in this Sub that you did not post? If Obligor_ID is a simple variable, then in order for it to be of any use, it would have to be declared outside of that Sub.
Another question - where is the module that includes this sub?
Can you post more info, please?
John
A sub seems to be a macro in Excel. It runs just like you would think. Ok i'm confused on why you would say it's not a macro. How should i declare it?
The macro itself doesn't really matter. But obligor_id is a public variable. I'm trying to assign it a value so i can use it down the line.
The module this is in shows up in Access under Modules
Thanks for your help!!!
Chris
That's true. In Word also, if you look at the code of a Macro - it will be in a Sub.A sub seems to be a macro in Excel.
But in Access it is best to get used to looking at them as two separate things - even though they both perform certain actions.
As John_G said - it would help to know exactly what you want to do so we could tell you how you can achieve it.
I have a feeling, though that a Function that returns and maybe also receives a value might be closer to what you need.
How can i get a macro to show up in access? How can i declare it? I don't know any other way to declare it besides public sub() or sub().
I'm trying to save the value from the form into a public variable(obligor_id).
Thanks!
Chris
Hi Chris -
You don't need a macro here - your one line of code does exactly what you want to do. (It's my own opinion, but I avoid MS Access macros at all costs!).
The best place to put your code would be the after update event of the [Obligor_ID] control on the form.
In the properties dialog for the control, scroll to After Update, select Event Procedure from the options, then click the "three dots" button to open the VB editor. You will see an "empty" sub, something like this:
Private Sub Obligor_ID_AfterUpdate()
End Sub
Add your line of code to make it look like this:
Private Sub Obligor_ID_AfterUpdate()
Obligor_ID = Forms![Borrower Details]![Obligor_id]
End Sub
Save the code, and you're done. It's that easy.
(If you knew how to code events already, sorry for the extra detail)
I suggest that you change the name of the global variable, though, so that it is not the same name as the form control, otherwise Access might not get it right.
HTH
John
I'm using tons of events now, but i didn't see a reason to use it here because they have to press a button anyway. So why not do everything i need to at once?
How can i create a macro that shows up in the list? My only question
Thanks!
Chris