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!

Requery help - must be simple

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
Hello,

I need help with trying to requery a list box on a sub form. In the On Current event I have an Event procedure with the following code:

Private Sub Form_Current()

Me.software_ListBox.Requery

End Sub

Software_ListBox is the name of the control on the sub form

But I keep getting this error message:

The expression On Current you entered as the event property setting produced the following error: A problem occurred while Microsoft Access was communicating with the OLE server or ActiveX Control.

* The expression may not result in the name of a macro, the name of a user-defined function, or [Event procedure].
* There may have been an error evaluating the function, event, or macro.

 
Danny,

I think that the statement you have would tell access to look for the combo box on 'Me', the main form.

If the combo's on the subform, you would need
Code:
  Me.SubformName.software_ListBox.Requery


HTH


John

Use what you have,
Learn what you can,
Create what you need.
 
Hey BoxHead

I tried what you suggested but it still gave me the same error. I also tired to use it as a button function but it still gave me the same error message.

I'm kinda lost on this so any help is appreciated.

Thanks
 
Hi!

What Access is trying to tell you with that error message is that it doesn't recognize, for whatever reason, what you have in the OnCurrent box in the property sheet for the form. The first thing to do is check the property sheet event tab to make sure the OnCurrent box says [Event Procedure]. If it does, I would delete the code in question, delete the [Event Procedure] from the property sheet, click on the ... beside the OnCurrent box and choose code builder. Finally, reenter the code.

hth Jeff Bridgham
bridgham@purdue.edu
 
Hi Jeff,

I also tried your suggestion, but that didn't work either.

I tried this docmd;

Private Sub Form_Current()
Dim qryString As String

qryString = "software_ListBox"

DoCmd.Requery "qryString"
End Sub


but that didn't work.

Thanks for the suggestions guys!

 
Danny,

Which OnCurrent Event are you using for this? The form or the subform?

John

Use what you have,
Learn what you can,
Create what you need.
 
Hi BoxHead

At first I tried using in on the sub form, but when that didn't work I tried using it on the main form.

I think it might be an Access problem as I now have no code in the On Current event and it still gives me the same error;

I have the method declaration like this in the sub form;

Private Sub Form_Current()

End Sub

and it still gives me the same error message.

Do I need to add a reference or something? I'm just a tad confused about this problem, as you can tell.

Thanks

Danny
 
Well it seems that there is a problem with my form as any event will trigger that error message. None of my other sub forms have this problem.

My sub form has one control, a list box.
The sub form is linked to the main form by the field Computer_Name. The row source for the list box is a query.

The query gets data from a table where the Computer_Name(field name) is equal to a control on the main form(also Computer_Name).

sql:
SELECT DISTINCTROW Software.Computer_Name, Software.[Audit Date], Software.Application, Software.Version
FROM Software
WHERE (((Software.Computer_Name)=[Forms]![Systems]![Computer_Name_Main]));

Now the table: I supect this is why I'm getting the error message.

The table is to house audit data that is imported from a text file. This data is gathered from a 3rd party program.

It has no primary key

the fields are like so:
Audit Date
Audit Time
Application
Volume
Volume Tag
Category
Path
Publisher
Creator
Version
User Name
Computer_Name

So can anyone see why I might be getting this message or any problems with the way this is setup?

thanks again

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top