Function Problem

R

Randy

Hello...ok I have a form with a button that I am trying to get to call on a
function. I have been able to do this and the funtion processes but I keep
getting an error. Now, the funtion works perfectly if I run it from the
switchboard/menu, but when run from the form button I get this error:

"The action or method requires a Table Name argument"

Here is the code I have:

Private Sub Update_All_Records_Click()
On Error GoTo Update_All_Records_Click_Err
DoCmd.OpenFunction Public_Income_Update_Step_1
Update_All_Records_Click_Exit:
Exit Sub
Update_All_Records_Click_Err:
MsgBox Error$
Resume Update_All_Records_Click_Exit
End Sub

Can anyone tell me what might be wrong with this? Am I calling on the
funtion incorrectly? Any help or suggestions agian will be gratly
appreciated. Thank you for your time!
 
F

fredg

Hello...ok I have a form with a button that I am trying to get to call on a
function. I have been able to do this and the funtion processes but I keep
getting an error. Now, the funtion works perfectly if I run it from the
switchboard/menu, but when run from the form button I get this error:

"The action or method requires a Table Name argument"

Here is the code I have:

Private Sub Update_All_Records_Click()
On Error GoTo Update_All_Records_Click_Err
DoCmd.OpenFunction Public_Income_Update_Step_1
Update_All_Records_Click_Exit:
Exit Sub
Update_All_Records_Click_Err:
MsgBox Error$
Resume Update_All_Records_Click_Exit
End Sub

Can anyone tell me what might be wrong with this? Am I calling on the
funtion incorrectly? Any help or suggestions agian will be gratly
appreciated. Thank you for your time!

You have a function named "Public_Income_Update_Step_1" and you wish
it to do whatever it is it does?

Private Sub Update_All_Records_Click()
On Error GoTo Update_All_Records_Click_Err
Call Public_Income_Update_Step_1
Update_All_Records_Click_Exit:
Exit Sub
Update_All_Records_Click_Err:
MsgBox Error$
Resume Update_All_Records_Click_Exit
End Sub

The word Call above is optional.

By the way, a function returns a value, i.e. MyVariable =
MyFunctionName().
I'm guessing you wish to perform an action.
Public_Income_Update_Step_1 should be a Sub Procedure, not a
Function.
 
R

Randy

Duh! Thanks Fred! I feel like an idiot! I thought I had tried that already
and it didn;t work so I tried this other way. I retried the "call" and of
course it worked.

Thanks for your assistance! Have a great day/weekend & holiday!
 

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