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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Ahhhh Illegal Operation!

Status
Not open for further replies.

keithgi

Technical User
Feb 1, 2002
20
GB
If only I knew why.
Whenever I add the following bit of code to one of my form modules I get the message "This program has performed an illegal operation. MSACCESS caused an invalid page fault in module VBA232.dll at 018f:0fb3b4e0.

The code is to clear the form and subform

Dim MySQL As String
MySQL = "SELECT * FROM [Instructions] WHERE False"
Me![ClientSearchSubform].Form.RecordSource = MySQL
Me!ClientSearchBox = Null
Me!ClientSearchbox.SetFocus

It works fine until I close the form and then re-open it. Thats when the invalid page message comes up.

Also, I don't know whether its related, but if I also add a SetFocus to the on Open command for the form I then get a standard message along the lines of "the command is not a recognised event or procedure" when I open the form.

Can anyone help please

Keith
 
I must admit that I don't understand what the query does because the Where clause isn't a condition on a field. If I had to guess, I would think that the query is causing your page fault because it is evaluated when the form is opened. It should also be evaluated when you set the recordsource, but it might not show up until you reopen the form. May I suggest an alternate method of clearing the form? Why not use recordset.AddNew? This will position the record pointer to a new record and the bound fields on your form will be blank. You can set the unbound fields blank as you did in your example.

dz
 
Hiya,

I've got to agree with FoxPro.

Your SQL works, but I doubt whether it is supported (i.e not designed to do this).
It is actually attempting to select a record where all fields are null (which logically, you will never have).

I'm not surprised by the memory error, but AM surprised that Access is complicated enough to be able to evaluate this statement and provide a blank record!

If you use Addnew, it will provide you with a blank record as you intend (remember that the record is not physically added until a field is changed anyway).

Regards,

Darrylle






"Never argue with an idiot, he'll bring you down to his level - then beat you with experience."
 
Thanks for the advice.

What is strange is that the identical code works fine in another form doing a similar thing. The WHERE False bit came from an Access wizard or sample database (I can't remember which).

The code only runs when a clear button is pressed so shouldn't have any effect when the form is opened. Even more strange is that when I convert my Access 95 database into XP I have absolutely no problems with it.

I'm not sure setting an AddNew command will work as the subform is a recordset based on all records in the source table which contain the word typed into my unbound 'search' box.

Perhaps I'll get the searchbox set to null and then do a requery instead.

Cheers
Keith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top