Run a converted Macro. Beginner's question.

guli75

New member
Local time
Today, 09:50
Joined
Aug 5, 2011
Messages
1
I am a beginner in Access VBA. I have created a macro in access to run a make table query and then rename the table. Now i want the current date to be part of the renamed table.
So, I converted the Macro to VBA and then put the date field in the code. When I run it from the VBA editor, using F5, it runs great and produced the right output. But, when I run the original macro, it is still creating the hard coded name as in the macro.

I want to know, how to run the converted macro, without having to go into the VBA editor mode.
 
Welcome to the Forum,

In your macro you need to select RunCode then below in the arguments you need to use the Elipsee to find the Converted Macro. By the way the Converted Macro will need to be changed from a Sub to Function otherwise you wont find it.
 
I am having the same problem, I changed it to a function, but when I try to put in the RunCode with argument converted macro title it tells me that the file isn't accessible? If i simply use the pull down menu to find the function it won't allow me to select it.
 
Please show your code and I can take a look and advice accordingly.
 
My code is below. It runs fine in VBA, I just can't get it to work as a macro, I would ideally like it to be a button on my form.


Option Compare Database
Private Function MyFunction()
Dim MyDb As DAO.Database
Dim rsEmail As DAO.Recordset
Dim sToName As String
Dim sSubject As String
Dim sMessageBody As String

Set MyDb = CurrentDb()
Set rsEmail = MyDb.OpenRecordset("Due Date", dbOpenSnapshot)

With rsEmail
.MoveFirst
Do Until rsEmail.EOF
If IsNull(.Fields(2)) = False Then
sToName = .Fields(2)
sSubject = "Open Action Item: " & .Fields(0)
sMessageBody = "Action Item due soon " & vbCrLf & _
"ID#: " & .Fields(0) & vbCrLf & _
"Due Date: " & .Fields(1)

docmd.SendObject acSendNoObject, , , _
sToName, , , sSubject, sMessageBody, False, False
End If
.MoveNext
Loop
End With

Set MyDb = Nothing
Set rsEmail = Nothing
End Function
 
Remove the Word Private before the Function name and you should be able to the use your function with a command button or macro.
 

Users who are viewing this thread

Back
Top Bottom