Results 1 to 8 of 8
  1. #1
    rjjhome is offline Novice
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    6

    Form Data problem

    Frist I am using MS Access 2003 on a XP system. I created 3 forms, one of the forms (I'll call it the main form) is used to allow the user to select which of the other 2 forms they wish to use by use of command buttons. My problem, when I click on a button on the main form to bring up one of the others, the form comes up but the form fields do not get populated from the data base ( i have the forms Record source property set), here the funny thing, if I right click on the sub form and select "remove filter/sort" the form then reads the data from the table and populates itself. Also if I do not use the "main" form to bring up my sub form and just open my sub form with out using the "Main" form the sub form does read the table data properly when opening.



    What does the "remove filter/sort" have to do with it?


    Thanks in advance

  2. #2
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    rjjhome,

    Post the code you are using. I just created the code below using the Wizard and it works. Have you got "Allow Additions" set to "Yes"?

    Code:
    Private Sub Command2_Click()
    On Error GoTo Err_Command2_Click
    
        Dim stDocName As String
        stDocName = "FrmOne"
        DoCmd.OpenForm stDocName
        
    Exit_Command2_Click:
        Exit Sub
    
    Err_Command2_Click:
        MsgBox Err.Description
        Resume Exit_Command2_Click
        
    End Sub

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by rjjhome View Post
    Frist I am using MS Access 2003 on a XP system.
    When you registered you said you were using Access 2007. Is that not the case?

  4. #4
    rjjhome is offline Novice
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    6

    Form Data problem

    Quote Originally Posted by ansentry View Post
    rjjhome,

    Post the code you are using. I just created the code below using the Wizard and it works. Have you got "Allow Additions" set to "Yes"?

    Code:
    Private Sub Command2_Click()
    On Error GoTo Err_Command2_Click
     
        Dim stDocName As String
        stDocName = "FrmOne"
        DoCmd.OpenForm stDocName
     
    Exit_Command2_Click:
        Exit Sub
     
    Err_Command2_Click:
        MsgBox Err.Description
        Resume Exit_Command2_Click
     
    End Sub

    My problem seems to be resolved: for some reason when I explicitly use the form name I am opening in the DoCmd the form does not fill with data, when I use a variable to hold the form name in the DoCmd it works.

    Original code (does not work):

    DoCmd.OpenForm "frmCerfofOrigin", acViewNormal, , , , acWindowNormal


    New code(works):

    Dim strnDocName As String
    strnDocName = "frmCerfofOrigin"
    DoCmd.OpenForm strnDocName, acViewNormal, , , , acWindowNormal


    Also I am using MS Access 2003 SP3

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by rjjhome View Post
    Also I am using MS Access 2003 SP3
    Did you just answer the question wrong or do you also use ac2007?

  6. #6
    ansentry's Avatar
    ansentry is offline Advanced Beginner
    Windows 7 64bit Access 2013
    Join Date
    May 2009
    Location
    Melbourne, Australia
    Posts
    67
    I just tried your code and it worked fine in my db;

    Code:
    DoCmd.OpenForm "FrmOne", acViewNormal, , , , acWindowNormal
    Also next to your User Name you have;

    Windows XP Access 2007 (version 12.0)
    is this correct?

  7. #7
    rjjhome is offline Novice
    Windows XP Access 2007
    Join Date
    May 2009
    Posts
    6

    Form Data Problem

    I have access to both MS Access 2003 and 2007. The machine I am using for this thread is MS Access 2003.

    As far as my problem, I have tried it several times using a variable to hold the form name and without the variable in the DoCmd and the only time it works for me is when I use the variable in the DoCmd. I do not know why, I posted the code, as far as I am concerned we can close this thread becasue the fix works for me.

    Thanks for the help.

  8. #8
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Quote Originally Posted by rjjhome View Post
    I have access to both MS Access 2003 and 2007. The machine I am using for this thread is MS Access 2003.

    As far as my problem, I have tried it several times using a variable to hold the form name and without the variable in the DoCmd and the only time it works for me is when I use the variable in the DoCmd. I do not know why, I posted the code, as far as I am concerned we can close this thread becasue the fix works for me.

    Thanks for the help.
    Thanks for clarifying the Version issue. You can close the thread if you want by using the link in my signature. Be advised that John is correct and either method *should* work to open a form. You may have some corruption in your db and if you don't take care of it now it will come back and bite you on the you-know-what. Your choice.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 11-25-2013, 10:56 AM
  2. Data Update Problem
    By Nosaj08 in forum Forms
    Replies: 3
    Last Post: 05-15-2009, 02:06 PM
  3. Replies: 9
    Last Post: 03-24-2009, 09:19 PM
  4. Form Data Entry Problem?
    By corystemp in forum Database Design
    Replies: 1
    Last Post: 03-21-2009, 02:29 PM
  5. Access Data PAge problem
    By csoft in forum Access
    Replies: 0
    Last Post: 04-24-2008, 03:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums