Results 1 to 11 of 11
  1. #1
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99

    Two Forms based on One Table

    Hi all,
    I have a form which contain too many lables that makes the form too big, and I'm thinking to seperate it to two forms.


    I add a cmd button on the first form and used DoCmd.OpenForm to open the second form, the two forms both have the primary key.
    Here comes the problem when I close the form after entering records, there's a system warning of data integrity. I also tried the acFormEdit, but it does not work.
    Any one have an idea?
    Thanks in advance.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Having that many fields implies a normalization issue. What do they all represent? You should be able to get around the problem by either closing the first form or at least forcing a save of the data when you open the second form. In my experience, the error you describe occurs when two forms have the same record dirtied. You might also consider a single form with a tab control to organize the data, which is what I would likely do.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99
    Thanks Paul.
    The form is used to record repair actions, but there's also many repair instructions about how to do it, and it gets too big.
    So if saved the first part before I dirty the second part that would be OK,right?

  4. #4
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99
    Hi Paul,
    I tried the tab control and it solved the issue perfectly, the only thing left is to decorate the tab control.
    So when I switch from one tab to another tab, it saved the first part and then edit the others, am I right?

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I suspect repair instructions should be in a one-to-many related table, but that's just a gut feeling. As to your question, no; moving from tab to tab does not trigger a save, presuming all the controls are directly on the form (as opposed to a subform). The tab control simply organizes the controls; they are all still on the same form.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  6. #6
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99
    Hi Paul, take a look at the attachment picture, it's something like that.
    Thanks for the explanation about the tabl control.

    By the way I tried to make the two forms work, but failed.
    Could you pleas take a look at the sample db and help find what's going wrong?

  7. #7
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99
    Hi Paul,
    I tried to insert data from the second form to the same table with a UPDATE query.
    The code I have is like this:
    Private Sub Command8_Click()
    Dim mySQL As String
    mySQL = "UPDATE tbl SET tbl.C= Me.C"
    mySQL = mySQL & " Where tbl.A=' " & Me.A & "'"

    CurrentDb.Execute mySQL, dbFailOnError

    End Sub

    There's a runtime erro 3061,need more parameter,expecting 1.
    Can you help find what's going wrong?

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Concatenate Me.C into the string. Is field a number datatype?

    mySQL = "UPDATE tbl SET tbl.C= " & Me.C
    mySQL = mySQL & " Where tbl.A='" & Me.A & "'"
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99
    No ,it's a string type

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,931
    Okay, then include the apostrophe delimiters just like with the Me.A concatenation.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    blueraincoat is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Mar 2011
    Location
    Shanghai,CHN
    Posts
    99
    Thanks June7,that works!

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

Similar Threads

  1. Replies: 0
    Last Post: 03-18-2011, 06:38 AM
  2. Replies: 2
    Last Post: 10-13-2010, 07:09 AM
  3. Replies: 1
    Last Post: 05-25-2010, 02:58 PM
  4. Replies: 2
    Last Post: 10-27-2009, 07:09 AM
  5. Replies: 4
    Last Post: 09-03-2009, 02:01 PM

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