Results 1 to 5 of 5
  1. #1
    Join Date
    Mar 2013

    Unanswered: Forms and Database Structure

    I am very new to VBA and what I know of Access is largely self taught from trial and error - likely why my current issue is arising. I have a Form1 that is used for data energy and bound to Table1. Form1 has a tab control with Option Group buttons used to pass true/false through to bound Table1 based on user selections. My problem: I want to create another subset of questions (another 7 approxiamtely) for users only when they answer 'false' to one of 30 questions on the form. I don't want this being stored for each primary key - but Table1 questions must occur for each primary key. I was hoping for Table1 - when user selects False - to create a new record in Table2 and inserting the primary key/compnay information from Table1/Form1. First thought was just to put an If statement in code that would pass the value from Table1 to Table2 in the OnUpdate event to the Option Group.

    I have code that converts the value being stored from the Option Group to actual true/false rather than -1/0.

    Thoughts? Maybe i should be using subforms..??

  2. #2
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Quote Originally Posted by TECVBA1 View Post

    ...I have code that converts the value being stored from the Option Group to actual true/false rather than -1/0...

    My first thought is that you need to explain the above! You do not refer to the individual Controls in an Option Group, in code, you refer to their position within the Option Group, itself. That's one of the reasons for the Option Group Control, the other being to only allow one of the possible selections to be made at one time. For some reason only known to the Access Gnomes, they name these structures FrameX, where X is a number. To refer to a selection made from one of these Groups you'd use something like

    If Me.Frame2 = 1 Then...'First button was selected
    If Me.Frame2 = 2 Then...'Second button was selected

    And so forth.

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Mar 2013
    Ok i will try and make it make it more simple:

    I want to pass records on a form to two tables (not just the bound table) is the user selects false:

    This is my code so far:

    If Me.Field2.Value = "False" Then

    I am looking at appending records now - seems this might work but i would rather this be automated. Assuming false as above I want Field1 (which will be primary key) only to pass to the new table.

  4. #4
    Join Date
    Mar 2013
    I am trying this under my AfterUpdate event, getting sytax error...-

    strSQL = "INSERT INTO tblTable2 " _
    & "([Field1]) " _
    & "SELECT '" & Me.Internal_ID
    DoCmd****nSQL strSQL

  5. #5
    Join Date
    Mar 2013
    Ok so more simple and solution...i wanted to pass Field1 value in table to another table based on unique values in Field2 in the bound table. In the AfterUpdate i used:
    Dim strSQL As String
    strSQL = "INSERT INTO tblTradeOptiontst " _
    & "([Internal_ID]) " _
    & "SELECT '" & Me.Internal_ID & "'"
    DoCmd.SetWarnings False
    DoCmd****nSQL strSQL
    DoCmd.SetWarnings True

Posting Permissions

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