Can't set value of controls in VBA code?

B

BruceInCalgary

I have a problem in my VBA code where I am trying to set the value for date
controls and checkbox controls. I get the following error each time I try
setting the date control's value to a date value from a VB variable: "The
setting you entered isn't valid for this property." I am using VB 6.3 and
Microsoft Access 2002.

Here is a code snippet:

Dim Report_StartDate As Date 'set from database table
Dim Report_EndDate As Date 'set from database table
....

'set the parameters on the form (using LANDesk Date Control)
Forms![PVR Update Well Inventories]!ReportStartDate.Value =
Report_StartDate
Forms![PVR Update Well Inventories]!ReportEndDate.Value = Report_EndDate

I also get the error message "You can't assign a value to this object" when
trying to set a checkbox on the form:

'select the report format (these are checkboxes)
Select Case Report_Format
Case "Net Gas Injected Report": Forms![PVR Update Well
Inventories]!chkNetGasInjectedReport.Value = True
Case "Gas In Place Report": Forms![PVR Update Well
Inventories]!chkGasInPlaceReport.Value = True
Case "Cumulative Gas Production Report": Forms![PVR Update Well
Inventories]!chkCumulativeGasProductionReport.Value = True
End Select

Any help to solve this problem would be greatly appreciated!

REgards, ...Bruce
 
D

Damian S

Hi Bruce,

If you drop the .value off the end of your items, does it work? eg:

Forms![PVR Update Well Inventories]!ReportStartDate = Report_StartDate

Damian.
 
B

BruceInCalgary

Hi Damian. I did try dropping the .value off the end of the code statements
and still got the same error. I forgot to mention that I am trying to set
these control values in the form_open() event - might this be part of the
problem?

Damian S said:
Hi Bruce,

If you drop the .value off the end of your items, does it work? eg:

Forms![PVR Update Well Inventories]!ReportStartDate = Report_StartDate

Damian.


BruceInCalgary said:
I have a problem in my VBA code where I am trying to set the value for date
controls and checkbox controls. I get the following error each time I try
setting the date control's value to a date value from a VB variable: "The
setting you entered isn't valid for this property." I am using VB 6.3 and
Microsoft Access 2002.

Here is a code snippet:

Dim Report_StartDate As Date 'set from database table
Dim Report_EndDate As Date 'set from database table
...

'set the parameters on the form (using LANDesk Date Control)
Forms![PVR Update Well Inventories]!ReportStartDate.Value =
Report_StartDate
Forms![PVR Update Well Inventories]!ReportEndDate.Value = Report_EndDate

I also get the error message "You can't assign a value to this object" when
trying to set a checkbox on the form:

'select the report format (these are checkboxes)
Select Case Report_Format
Case "Net Gas Injected Report": Forms![PVR Update Well
Inventories]!chkNetGasInjectedReport.Value = True
Case "Gas In Place Report": Forms![PVR Update Well
Inventories]!chkGasInPlaceReport.Value = True
Case "Cumulative Gas Production Report": Forms![PVR Update Well
Inventories]!chkCumulativeGasProductionReport.Value = True
End Select

Any help to solve this problem would be greatly appreciated!

REgards, ...Bruce
 

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