Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2009
    Posts
    2

    Unanswered: Opening forms with subforms

    I am editing someone elses code who is no longer availible.

    The code allows people to search for a member by the lastname or S.S#, however I am editing in a way to search by Member Number.

    The program first has a form with 3 combo boxes, first two are sorted by lastname/SS#, and a third I created sorted by Member Number.

    In the code under the event AfterUpdate I ran the code that was working, sorting by SS#, and recorded all of the variables that were changed under CmbSS#_AfterUpdate after selecting a person, finishing with a DoCmd.OpenForm "FrmEditEng"

    I then hardcoded these changes to variables into the section for CmbMemberID_AfterUpdate, again finishing with a DoCmd.OpenForm "FrmEditEng". With the intent to then change the variables to be altered through the selected combo box after ensuring it worked.

    However when the old code runs, when it hits the line DoCmd.OpenForm "FrmEditEng", it opens up a different form, "FrmGetSkills" which is a sub-form of FrmEditEng. When my new code runs, it heads straight to FrmEditEng. Unfortunately, FrmGetSkills it what loads the RecordSource, so when FrmEditEng loads first it attempts checks for record count and the program crashes when it comes back 0.

    TLDR version, Trying to open a form that has subforms, old code opens subforms first, my new code (same syntax afaik) opens main form first which causes it to go to error.

  2. #2
    Join Date
    Dec 2009
    Posts
    2
    To further confuse me, I took the new code, copy pasted it into the very first line of the old comboBox_update sections, and it worked fine. So the code within my new CmbBox_update section doesnt work, but the same code under a different event does.

    Code:
    MyCrit = "SocialSecurity = '130268411'"
    JHReport = MyCrit
    JHName2 = JhName1
    DoCmd.OpenForm "FrmEditEng"
    is the code that I am using. JHReport, MyCrit, JHName2, and JHName1 are all strings.

    UnionID is the name of the new comboBox I made, if I select from it and this block runs

    Code:
    Private Sub CmbUnionID_AfterUpdate()
    
    MyCrit = "SocialSecurity = '130268411'"
    JHReport = MyCrit
    JHName2 = JhName1
    DoCmd.OpenForm "FrmEditEng"
    
    End Sub
    it goes straight to the EditEng form and crashes.

    If I run this block
    Code:
    Private Sub CmbName_AfterUpdate()
    
    MyCrit = "SocialSecurity = '130268411'"
    JHReport = MyCrit
    JHName2 = JhName1
    DoCmd.OpenForm "FrmEditEng"
    
    End Sub
    It works properly

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •