Macro not working from a form but does standalone

G

Guest

I run a mcro on a 'on click' event from a button within a form the code is
attached below. It is designed to transfer records from one table to another.
The message appears , so the if then statement is being executed.

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

Dim stDocName As String

stDocName = "archive data"
If (Me.[Yesoption]) And Me.Text7 = -1 And Me.[Batch to archive] > 0 Then
MsgBox ("Archiving ALL batch Details")
DoCmd.RunMacro ("Archive Data")
End If

Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click

End Sub

The macro works fine when run as a standalone' macro, but when I execute it
from within the form environment, the macro does not do anything.
 
G

Guest

I can't see why the macro shouldn't run, make a code break and see if you
enter the if statement, it could be that you are not getting to the run macro
command.
see if the Me.[Yesoption] And Me.Text7 = -1 And Me.[Batch to archive] > 0
gettinf there values.
do you get a message box?
 
G

Guest

yes i ge the msgbox, i also added one within the if then clause just bbefore
the endif and it appears also, indicating the the run mcao command is being
processed


so it still confuses
--
Regards


Patrick Stubbin


Ofer said:
I can't see why the macro shouldn't run, make a code break and see if you
enter the if statement, it could be that you are not getting to the run macro
command.
see if the Me.[Yesoption] And Me.Text7 = -1 And Me.[Batch to archive] > 0
gettinf there values.
do you get a message box?

Patrick Stubbin said:
I run a mcro on a 'on click' event from a button within a form the code is
attached below. It is designed to transfer records from one table to another.
The message appears , so the if then statement is being executed.

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

Dim stDocName As String

stDocName = "archive data"
DoCmd.RunMacro ("Archive Data")
End If

Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click

End Sub

The macro works fine when run as a standalone' macro, but when I execute it
from within the form environment, the macro does not do anything.
--
Regards


Patrick Stubbin
 
G

Guest

Try to run the macro without runing the macro. I mean that if you have a
macro that open a form then instead of writing docmd.runnacro "macroname"
write docmd.openform "formname"

Patrick Stubbin said:
yes i ge the msgbox, i also added one within the if then clause just bbefore
the endif and it appears also, indicating the the run mcao command is being
processed


so it still confuses
--
Regards


Patrick Stubbin


Ofer said:
I can't see why the macro shouldn't run, make a code break and see if you
enter the if statement, it could be that you are not getting to the run macro
command.
see if the Me.[Yesoption] And Me.Text7 = -1 And Me.[Batch to archive] > 0
gettinf there values.
do you get a message box?

Patrick Stubbin said:
I run a mcro on a 'on click' event from a button within a form the code is
attached below. It is designed to transfer records from one table to another.
The message appears , so the if then statement is being executed.

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click

Dim stDocName As String

stDocName = "archive data"
MsgBox ("Archiving ALL batch Details")
DoCmd.RunMacro ("Archive Data")
End If

Exit_Command1_Click:
Exit Sub

Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click

End Sub

The macro works fine when run as a standalone' macro, but when I execute it
from within the form environment, the macro does not do anything.
--
Regards


Patrick Stubbin
 

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

Similar Threads


Top