Error on subform refresh

Dmitriy

Registered User.
Local time
Today, 14:28
Joined
May 16, 2008
Messages
11
I'm working on an Access project (an .adp file) which is connected to SQL Server 2005. I have a form and a subform, and the subform gets records from a stored procedure called PETech. PETech takes in a parameter @act (a code) and returns all records where a certain column matches that parameter. I have a combo box in my main form with a list of all possible codes. The user should be able to pick a code and the subform will refresh to list only the records matching that code.

The main form is called Form1, the subform is called PE_subform, and the combo box is cbeActCde.
I put the following in the Input Parameters property of my subform: @act nvarchar(8) = [Forms]![Form1]![cbeActCde]. In the code for the AfterUpdate event of the combo box, I put: Forms(PE_subform).Refresh.

When I open the form and pick a code, the list refreshes and shows the right records, but the form crashes immediately on the Refresh statement in the VB code and I get this error: "Run-time error '7874': PE Database can't find the object 'PETech'."

Does anyone know what's wrong? Again, I'm getting the right results so the input parameters are working, but the program crashes as soon as the results are returned. Should I be using another function instead of Refresh? I tried Requery but that didn't work.

Thanks
 
That didn't work either. Now it apparently can't find the subform:
"Run-time error '2450': PE Database can't find the form 'PE_subform' referred to in a macro expression or Visual Basic code."
 
I figured it out. I was using the name of the subform instead of the name of its control (the 2 names were different). The Refresh method actually didn't work anyway, I had to do this: Me.PETechSub.Requery (where PETechSub is the name of the container holding the subform).
 

Users who are viewing this thread

Back
Top Bottom