In Access, wait before running a macro automatically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a macro with conditions that vary the action depending on the number
of records in a subform.
Using a =Count([FieldName]) formula in the Subform field I have got this to
work but running the macro "on current" in the form, runs it before
calculating the value in the subform field so it always takes the value to be
zero.
Could somebody please suggest a way of automatically running the macro after
the field has calculated its result.
 
One post per issue please. You don't need people answering in one group if
already answered in another.
 
Perhaps if you could describe what you are trying to do it would help
someone sort out an answer for you. What are you wanting the macro to do?
 
The macro itself works, and if run manually performs the desired process. It
is simply how to run it that I would like suggestions for

Lynn Trapp said:
Perhaps if you could describe what you are trying to do it would help
someone sort out an answer for you. What are you wanting the macro to do?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


pezza88 said:
I have a macro with conditions that vary the action depending on the number
of records in a subform.
Using a =Count([FieldName]) formula in the Subform field I have got this to
work but running the macro "on current" in the form, runs it before
calculating the value in the subform field so it always takes the value to be
zero.
Could somebody please suggest a way of automatically running the macro after
the field has calculated its result.
 
I understand that, but without more information, I'm not sure I can help
you. Why does the number of records in the record source change the macro
action? If you can let me know this, then we might be able to figure out a
way to make it do what you want.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


pezza88 said:
The macro itself works, and if run manually performs the desired process. It
is simply how to run it that I would like suggestions for

Lynn Trapp said:
Perhaps if you could describe what you are trying to do it would help
someone sort out an answer for you. What are you wanting the macro to do?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


pezza88 said:
I have a macro with conditions that vary the action depending on the number
of records in a subform.
Using a =Count([FieldName]) formula in the Subform field I have got
this
to
work but running the macro "on current" in the form, runs it before
calculating the value in the subform field so it always takes the
value to
be
zero.
Could somebody please suggest a way of automatically running the macro after
the field has calculated its result.
 
If there are no records to be displayed, I want the macro to hide certain
objects on the form, however if there are one or more records I want them to
be displayed. Simply using conditions in the macro is how I have done this.
(I am using Access 2000)

Lynn Trapp said:
I understand that, but without more information, I'm not sure I can help
you. Why does the number of records in the record source change the macro
action? If you can let me know this, then we might be able to figure out a
way to make it do what you want.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


pezza88 said:
The macro itself works, and if run manually performs the desired process. It
is simply how to run it that I would like suggestions for

Lynn Trapp said:
Perhaps if you could describe what you are trying to do it would help
someone sort out an answer for you. What are you wanting the macro to do?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


I have a macro with conditions that vary the action depending on the
number
of records in a subform.
Using a =Count([FieldName]) formula in the Subform field I have got this
to
work but running the macro "on current" in the form, runs it before
calculating the value in the subform field so it always takes the value to
be
zero.
Could somebody please suggest a way of automatically running the macro
after
the field has calculated its result.
 
Try putting this in the current event of your form:

Dim rst As DAO.Recordset
Dim lngCount As Long
Set rst = Me.RecordsetClone

With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount
End With

If lngCount > 0 Then

DoCmd.RunMacro "YourMacro"

End If


--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


pezza88 said:
If there are no records to be displayed, I want the macro to hide certain
objects on the form, however if there are one or more records I want them to
be displayed. Simply using conditions in the macro is how I have done this.
(I am using Access 2000)

Lynn Trapp said:
I understand that, but without more information, I'm not sure I can help
you. Why does the number of records in the record source change the macro
action? If you can let me know this, then we might be able to figure out a
way to make it do what you want.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


pezza88 said:
The macro itself works, and if run manually performs the desired
process.
It
is simply how to run it that I would like suggestions for

:

Perhaps if you could describe what you are trying to do it would help
someone sort out an answer for you. What are you wanting the macro
to
do?
--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


I have a macro with conditions that vary the action depending on the
number
of records in a subform.
Using a =Count([FieldName]) formula in the Subform field I have
got
this
to
work but running the macro "on current" in the form, runs it before
calculating the value in the subform field so it always takes the value to
be
zero.
Could somebody please suggest a way of automatically running the macro
after
the field has calculated its result.
 
Thank you.

Lynn Trapp said:
Try putting this in the current event of your form:

Dim rst As DAO.Recordset
Dim lngCount As Long
Set rst = Me.RecordsetClone

With rst
.MoveFirst
.MoveLast
lngCount = .RecordCount
End With

If lngCount > 0 Then

DoCmd.RunMacro "YourMacro"

End If


--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


pezza88 said:
If there are no records to be displayed, I want the macro to hide certain
objects on the form, however if there are one or more records I want them to
be displayed. Simply using conditions in the macro is how I have done this.
(I am using Access 2000)

Lynn Trapp said:
I understand that, but without more information, I'm not sure I can help
you. Why does the number of records in the record source change the macro
action? If you can let me know this, then we might be able to figure out a
way to make it do what you want.

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


The macro itself works, and if run manually performs the desired process.
It
is simply how to run it that I would like suggestions for

:

Perhaps if you could describe what you are trying to do it would help
someone sort out an answer for you. What are you wanting the macro to
do?

--
Lynn Trapp
MS Access MVP
www.ltcomputerdesigns.com
Access Security: www.ltcomputerdesigns.com/Security.htm


I have a macro with conditions that vary the action depending on the
number
of records in a subform.
Using a =Count([FieldName]) formula in the Subform field I have got
this
to
work but running the macro "on current" in the form, runs it before
calculating the value in the subform field so it always takes the
value to
be
zero.
Could somebody please suggest a way of automatically running the macro
after
the field has calculated its result.
 
Back
Top