Refreshing a form in ADP

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

Guest

I have a form "frmAirspaceBlockSched" that is bound to a View and I open it
to the date selected on a Calender Control with the following VBA code:

stLinkCriteria = "DateSched = '" _
& Format(ocxcalender.Object.Value, "yyyy-mm-dd") & "'"

DoCmd.OpenForm "frmAirspaceBlockSched", , , stLinkCriteria

This works just fine but once the user is on the form
"frmAirspaceBlockSched" I want them to be able to move to the next and/or the
previous day. I use the DateAdd function to change the Calender value and
then try to refresh the from using the following code:
Me.Filter = "[DateSched]=" _
& Format(Form_frmSwitchboard.ocxcalender.Value, "yyyy-mm-dd") & "'"

This worked fine as an MDB but errors out now. I'm thinking I should use a
stored procedure but not sure if there isn't a way to make this work. Any
ideas? Thanks for helping.
 
I figured it out. I needed to change the ServerFilter not just the filter, so
here is what the code looks like that works for the Previous Day command
button:

Form_frmSwitchboard.ocxcalender.Value = DateAdd("d", -1, Me.txtHeaderDate)
Me.Refresh
Me.ServerFilter = "DateSched= '" &
Format(Form_frmSwitchboard.ocxcalender.Value, "yyyy-mm-dd") & "'"
 

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

Access Form Refresh 1
Syntax Error 4
Can't use dd/mm/yyyy format 6
filter on dates 2
DTPicker: Incrementing Time Value 6
OpenForm action canceled 1
Retrieve the records based on the time range 3
Date formats 1

Back
Top