Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Application-defined or object-defined error

Status
Not open for further replies.

striker73

MIS
Jun 7, 2001
376
0
0
US
I have the following line of code in a VBA global module in my Access database, but I am getting an "Application-defined or object-defined error". Can anyone help me out?

Forms!frmTestReport.chkScanned.Value = TestReport_Query.fields("Scanned")

It looks like TestReport_Query.fields("Scanned") is returning a false value, so I'm not sure why it won't set the value of the checkbox on my form. Help!!
 
There is to little information.

We need to see how you've declared and opened the TestReport_Query recordset.

Roy-Vidar
 
I tried to make it a little simpler and to eliminate any other issues that could be going on, so I just tried to set it to True, but it gives me the same error.

Code:
Forms!frmTestReport.chkScanned.Value = True
 
OK - so it is the public that's the "root" of the challenge.

1 - ensure the public is declared at the top of the form with the keyword public
2 - ensure the form is open
3 - try dropping of the .Value

Roy-Vidar
 
What exactly do you mean by declaring the public at the top of the form? I'm using a global module, so it's not tied directly to my form in question. In my global module, I have:

Code:
Option Compare Database
Option Explicit

Public User_ID As Integer
Public NewClient as Boolean
etc.


Public Sub LoadTestReport()
     Forms!frmTestReport.txtReportName = "Abc"
     Forms!frmTestReport.chkScanned.Value = True << Line with issues

End Sub

I've tried it without the .Value, but that didn't seem to work either. It works fine with the text box, however.
 
Oups - my mistake, I was convinced you where trying to reference a public variable of the form - being in the VBA forum I just overlooked the mentioning of the checkbox in your initial question.

Then some of the traditional steps are in the lines of:

* check for correct name
* it is a checkbox
* is it bound to a field that's not updateable - or is the recordset it's bound to in a not updateable state
* does it have a calculated controlsource

For good measures, try out some other types of syntax:

[tt]Forms!frmTestReport!chkScanned
Forms("frmTestReport")("chkScanned").Value
Forms("frmTestReport").controls("chkScanned").Value[/tt]

Try declaring, and set a variable to the form:

[tt]Public Sub LoadTestReport()
dim frm as form
set frm= Forms!frmTestReport
frm("txtReportName")="ABC"
frm("chkScanned")=True
set frm=nothing
End Sub[/tt]

What happens if you try to reference the control in the immidiate pane (ctrl+g):

[tt]? Forms!frmTestReport!chkScanned.Value[/tt]

If none of this get you in the right direction, I'm wondering if there might be other issues, corruption, MDAC version...

Roy-Vidar
 
Oh, I am such a dork! I figured out what was going on. I have two forms: frmTestReport and frmAddTestReport. My checkbox only ended up on one of those forms, not the other, so it was erroring out on the other. Thanks for your help!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top