Visual Basic for Open Form, set value of object as ""

K

Karissa

I have a report that gives a count of records for a date range. I want the
user to be able to run the report without having to choose the report screen
and find it on the list, but I want to maintain consistency in using the
date-range on the reports form (plus, I want it to be accessible from the
report menu without having two of the same report). My solution is for the
user to push the button and the report menu to open already populated with
the report name. I tried creating a macro to openform "frmdaterange" (the
reports form) and setvalue of "combo100" (the list of reports) to
"ReportName". It opened the form, but did not set the value. SO, I thought
perhaps I'd write a code for it. This is where I'm stuck...this is what I
have so far, working on one step at a time:

Public Function WinbackTargetCountByAnalyst(DateRange As String)

[frmDateRange] = DateRange

Docmd.OpenForm DateRange

End Function



I keep getting a compile error, external name not defined. When I change it
to:

Forms![frmDateRange] = DateRange

Docmd.OpenForm DateRange

I get "invalid use of property".

Help, please?
 
C

Clifford Bass

Hi Karissa,

You have to open the form first before you can assign the date range.
And you have to tell it what control to place the range into. So if the text
box for the date range is named "txtDateRange", you might have this:

Public Function WinbackTargetCountByAnalyst(DateRange As String)

Docmd.OpenForm DateRange
[Forms]![frmDateRange][txtDateRange].Value = DateRange

End Function

Hope that helps,

Clifford Bass
 

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