Results 1 to 6 of 6
  1. #1
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68

    Change insert into code on the condition of a yes/no list box becoming visible

    If Me.TxtActualBenchmark.Enabled = False Then CurrentDb.Execute "INSERT INTO Scorecards (Results)" & _
    "VALUES('" & Me.YesNoList & "');"

    'Add data to form
    CurrentDb.Execute "INSERT INTO Scorecards (ForTheMonth,FiscalYear,Groups,Contact,Goals,Bench marks,Results,Comments)" & _
    "VALUES('" & Me.ComboMonth & "','" & Me.ComboFiscal & "','" & Me.ComboDepartment & "','" & Me.txtContact & "','" & Me.ComboGoals & "','" & Me.txtBenchmarks & "','" & Me.TxtActualBenchmark & "','" & Me.txtComments & "');"
    'message box


    Private Sub ComboGoals_AfterUpdate()
    Select Case Me.ComboGoals
    Case "Provision 2 and universal free meals to all students"
    YesNoList.Visible = True


    Case Else
    YesNoList.Visible = False
    End Select


    Select Case Me.ComboGoals
    Case "Provision 2 and universal free meals to all students"
    TxtActualBenchmark.Enabled = False
    Case Else
    TxtActualBenchmark.Enabled = True
    End Select


    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    Code:
    ''NO QUOTES FOR BINARY VALUES!
    
    If NOT TxtActualBenchmark.Enabled  Then CurrentDb.Execute "INSERT INTO Scorecards (Results)" & _
    "VALUES(" & YesNoList & ");"
    
    Private Sub ComboGoals_AfterUpdate()
         YesNoList.Visible = ComboGoals = "Provision 2 and universal free meals to all students"
         TxtActualBenchmark.Enabled =NOT YesNoList.Visible
    End sub

  3. #3
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    I almost have it working . I have another question? Should disabling txtActualBenchmark stop my message box? I'd like for it to stop the message box.

    If Nz(Me.TxtActualBenchmark, "") = "" Then ' No business unit
    MsgBox ("Please add Results!"), vbOKCancel ' Tell user
    Me.txtContact.SetFocus ' Focus the control
    Exit Sub ' Exit the method
    End If ' End the IsNull test

  4. #4
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    I figured out how to get the message box to stop

  5. #5
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    Where should I put this part? Under the CmdAdd?

    If NOT TxtActualBenchmark.Enabled Then CurrentDb.Execute "INSERT INTO Scorecards (Results)" & _
    "VALUES(" & YesNoList & ");"

  6. #6
    GinaFlan is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2014
    Location
    Texas
    Posts
    68
    Firgured it out, I did this instead
    Private Sub Comboyesorno_Change()
    Me.TxtActualBenchmark.Value = Me.Comboyesorno.Column(0)
    End Sub

    Thank you for the other code it helped a lot

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

Similar Threads

  1. Visible/Not Visible based on condition VBA
    By BLFOSTER in forum Programming
    Replies: 3
    Last Post: 07-15-2014, 01:29 PM
  2. Replies: 2
    Last Post: 12-14-2013, 08:40 AM
  3. Replies: 2
    Last Post: 01-06-2011, 04:38 AM
  4. Replies: 1
    Last Post: 09-27-2010, 04:27 AM
  5. Change as per condition font color
    By miziri in forum Programming
    Replies: 1
    Last Post: 08-20-2009, 04:23 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