Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2005
    Posts
    7

    Unanswered: Default Value needs to change with yes/no field

    I'm very new to MS access and VBA coding but need some help.
    I have a field labelled ExtWarryn which is setup as data Type "Yes/No"
    I need the default value in another field of the same table to change when the yes/no button is checked and unchecked. It doesn't appear that you can use any type of IF statement in the Default Value field.

    I found this code but couldn't get it to work after I added my field names etc.

    Private Sub HomePhone_AfterUpdate()
    If Left(Me.HomePhone, 3) = "202" Then
    Me.State = "DC"
    ElseIf Left(Me.HomePhone, 3) = "301" Then
    Me.State = "MD"
    ElseIf Left(Me.HomePhone, 3) = "703" Then
    Me.State = "VA"
    End If
    End Sub

    Does anybody have any ideas or have I explained myself properly?
    Thanks

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    I don't know what Type the other field is nor what the value might be you would like placed into that field if the ExtWarryn control is either Checked or not, but the general concept would be this:

    In the OnClick event for your ExtWarryn CheckBox control:
    Code:
    If Me.ExtWarryn.Value = True Then
       ' If the ExtWarryn check box is checked by user then....
       Me.myOtherFormField = Whatever value (string, numerical, boolean)
    Else
       ' If the ExtWarryn check box is NOT checked by user then....
       Me.myOtherFormField = Whatever value (string, numerical, boolean)
    End If
    Or you could simply have...

    Code:
    If Me.ExtWarryn.Value = True Then
       ' If the ExtWarryn check box is checked by user then....
       Me.myOtherFormField = Whatever value (string, numerical, boolean)
    End If
    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    You could keep a table of area codes and states then use a simple dllookup and not have to worry about hard coding each individual area code...
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  4. #4
    Join Date
    Nov 2005
    Posts
    7

    Thanks

    Thanks for the help, the tip works great.
    I really appreciate it.
    Rob

Posting Permissions

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