PDA

View Full Version : Refresh underlying queries



ijswalker
08-27-2006, 05:06 PM
Hi,

I have a UserForm to expediate data entry in Access. However, before I run a report I have to refresh all of my queries. Is there a way for this to automatically happen when I clixk on a button. I have tried the Do Command but can't seem to get that to work.

Thanks

Ian

geekgirlau
08-28-2006, 03:44 AM
What do you mean you have to refresh the queries? If they are action queries (update, append, delete, make table) then DoCmd.OpenQuery should work.

matthewspatrick
08-28-2006, 05:06 AM
I have a UserForm to expediate data entry in Access.

Strictly speaking, Access does not have UserForms. The UserForm is a VBA construct used in most Office apps, but not Access. Access has its own Form object model, for better or for worse.


However, before I run a report I have to refresh all of my queries. Is there a way for this to automatically happen when I clixk on a button. I have tried the Do Command but can't seem to get that to work.

For reports that require complex calculations, I often use "temp" tables and a series of action queries to stage the data.

Depending on what I need to do, I typically use:


With DoCmd
.SetWarnings False
.OpenQuery "qryAction"
' more as needed
.SetWarnings True
End With


or


With DoCmd
.SetWarnings False
.RunSQL "some SQL string"
' more as needed
.SetWarnings True
End With


I'll run that code either in the click event for the CommandButton on the Form that users should use to launch the report (usually if the Form includes controls that set parameters for the report), or in the Open event of the report itself.

OBP
08-29-2006, 04:08 AM
Posting an example copy of the zipped database would help us understand your problem.