Set Current Row in SubForm datasheet

T

Todd H

I have a form that has "line item" information, and I have a subform
that displays the "billing periods" and their actual or forecast cost
for each period. I am trying to set the current row in the subform to
the "billing period" that was 3 months ago, so that I do not have to
scroll down everytime to get to the 'current' billing period (I chose
3 months, so I could still view the last two entries in the
datasheet. I still want to be able to view all the records, so a
filter is not what I am after.

I am trying to add the code at the OnCurrent property of the Subform,
and can't get DoCmd.GotoRecord or DoCmd.FindRecord to work; I can't
even seem to be able to assemble any code that will work.

Here are the specifics:

Master form: frmEstimateLineItems
SubForm: frmPaymentsSubform; and [BillingPeriodEndDate] is a field in
the Subform I am basing this on.

I need to set te datasheet to have the first row be:

[BillingPeriodEndDate] = Between DateAdd("m",-3,Date()) And
DateAdd("m",-4,Date())

Where each datasheet row is based on [BillingPeriodEndDate]
 
T

Todd H

Well here is the code I have gotten, but I can't seem to get the
GoToRecord formatted correctly:

Me!frmPaymentSubform.SetFocus
DoCmd.GoToRecord , acActiveDataObject, acGoTo, BillingPeriodEndDate =
"Between" & DateAdd("m", -3, Date) & "And" & DateAdd("m", -4, Date)

Please help. Thanks,

Todd
 
C

Carl Rapson

Todd H said:
Well here is the code I have gotten, but I can't seem to get the
GoToRecord formatted correctly:

Me!frmPaymentSubform.SetFocus
DoCmd.GoToRecord , acActiveDataObject, acGoTo, BillingPeriodEndDate =
"Between" & DateAdd("m", -3, Date) & "And" & DateAdd("m", -4, Date)

Please help. Thanks,

Todd

You need spaces after 'Between' and around 'And'. Also, you might need to
bracket your dates with "#":

DoCmd.GoToRecord , acActiveDataObject, acGoTo, BillingPeriodEndDate =
"Between #" & DateAdd("m", -3, Date) & "# And #" & DateAdd("m", -4, Date) &
"#"

Carl Rapson
 

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