Report problem: "DoCmd.Control" error in VB

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

Guest

Hello,

I have an MS Access database that was developed using Access97; I have
subsequently upgraded my system and am using Access2003--the database is
working flawlessly except for an error that has arisen with one of the
Reports which uses a series of check boxes to add specific data from a series
of different Fields to a Report.

When I clcik the button set to "Preview Report" in the database, I get the
message "Compile error: Method or data member not found" and the command
"Control" is highlighted in the following script for the Report in the VB
debugger:

strMsg = "REPORT has less than 7 fields enter 1 / REPORT contains 7 fields
or more enter 2"
strInput = InputBox(Prompt:=strMsg, Title:="Choose an Option !", XPos:=2000,
YPos:=2000)
If strInput = "" Then
DoCmd.DeleteObject acTable, "GENERA"
DoCmd.Control "MyQuery"
Exit Sub
Else
If strInput = 1 Then
stDocName = "MyReport_portrait"
DoCmd.OpenReport stDocName, acPreview
End If
If strInput = 2 Then
stDocName = "MyReport_landscape"
DoCmd.OpenReport stDocName, acPreview
End If
If strInput > 2 Then
DoCmd.RunMacro "Macro1"
End If
End If


End Sub

I really don't know much about VB, so I am really at a loss!!!! I would
greatly appreciate any suggestions you might have.

Thanks in advance,
Grahamk
 
GrahamK said:
I have an MS Access database that was developed using Access97; I have
subsequently upgraded my system and am using Access2003--the database is
working flawlessly except for an error that has arisen with one of the
Reports which uses a series of check boxes to add specific data from a series
of different Fields to a Report.

When I clcik the button set to "Preview Report" in the database, I get the
message "Compile error: Method or data member not found" and the command
"Control" is highlighted in the following script for the Report in the VB
debugger:

strMsg = "REPORT has less than 7 fields enter 1 / REPORT contains 7 fields
or more enter 2"
strInput = InputBox(Prompt:=strMsg, Title:="Choose an Option !", XPos:=2000,
YPos:=2000)
If strInput = "" Then
DoCmd.DeleteObject acTable, "GENERA"
DoCmd.Control "MyQuery"
Exit Sub
Else


I never heard of the method "Control". Either something
went wrong in the conversion or you just made that line up.
Since you didn't explain what that line is supposed to
accomplish, I have no idea what you should be using instead.
 
Back
Top