Free Lessons
Courses
Seminars
TechHelp
Fast Tips
Templates
Topic Index
Forum
ABCD
 
Home   Courses   TechHelp   Forums   Help   Contact   Merch   Join   Order   Logon  
 
Back to Access Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
Error Opening Form
Ross Paulson 
    
15 months ago
Newbie here,

I have a parent form "Main_draw";  it has 2 conintuous subforms (frmDriverCont & frmPayeeCont).  I have some vba attached the "frmDriverCont" that runs a Filter via the Form_Current() event.

The vba works exactly like i need it to, as it filters some records in the frmPayeeCont sub form.

The issue I am having is I get a runetime error 2455 when i open the Main_draw form.  I can continue on and everything works 100%.  I just cant seen to be able to get around this initial error.

Thanks for any assistance,
Ross
Kevin Robertson  @Reply  
          
15 months ago
Run-time error '2455': You entered an expression that has an invalid reference to the property Form/Report

What is is the code in the subform?
Ross Paulson OP  @Reply  
    
15 months ago
here is the sub form code:

Private Sub Form_Current()

'this runs when you select a record
SelectedID = ID 'write the ID to the ID box on the subfoem

'''''''''''''''''''''''

If Not IsNull(Me.SelectedID) Then 'write the data to the Parent form
        Me.Parent!TxtFullName = Me!FullName
        Me.Parent!txtDriverID = Me.SelectedID
        Me.Parent!TranNo = Me!TranNo
        
  End If
  
  '''''''''filters teh payee subform

    Dim DriverID As String
    Dim subformControl As Object

    ' Ensure the parent form and subform are fully loaded before proceeding
    If Me.Parent Is Nothing Then Exit Sub  ' Check that the parent form exists

    ' Get the selected Driver ID from the current record in the subform
    DriverID = Nz(Me.ID, "")

    ' Set reference to the subform control (Payee subform on the main form)
    Set subformControl = Me.Parent!frmPayeeCont

    ' If DriverID is valid, apply the filter on the Payee subform
    If DriverID <> "" Then
        ' Apply the filter to the Payee subform (frmPayeeCont) on Main_Draw
        subformControl.Form.Filter = "PID IN (SELECT PID FROM Driver_Payee WHERE ID = '" & DriverID & "')"
        subformControl.Form.FilterOn = True
    Else
        ' If no Driver ID is provided, remove the filter
        subformControl.Form.FilterOn = False
    End If

  '''''''''''''
  

End Sub
Kevin Robertson  @Reply  
          
15 months ago
When you click Debug (in the error dialog) which line is highlighted?
Ross Paulson OP  @Reply  
    
15 months ago
subformControl.Form.Filter = "PID IN (SELECT PID FROM Driver_Payee WHERE ID = '" & driverID & "')"
Ross Paulson OP  @Reply  
    
15 months ago
not an expert, but chat GPT say probably due to teh fact the subform amy not be laoded yet?
Ross Paulson OP  @Reply  
    
15 months ago
bump

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Access Forum.
 

Next Unseen

 
New Feature: Comment Live View
 
 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 5/1/2026 9:50:04 PM. PLT: 0s