Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms / July 2007

Tip: Looking for answers? Try searching our database.

Text box update with If..Then

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
maceslin@gmail.com - 16 Jul 2007 14:10 GMT
New to coding...

I want to use a selection in a combo box (cboClassification) to
populate a text box (Con_Num_Class) on the same form.  The code I am
using is not working

Private Sub cboClassification_()
If cboClassification = "UNCLASS" Then
   Me!Con_Num_Class = "U"
Else
   If cboClassification = "CONFIDENTIAL" Then
       Me!Con_Num_Class = "C"
   Else
       If cboClassification = "SECRET" Then
           Me!Con_Num_Class = "S"
       End If
   End If
End If
End Sub

Any suggestions?

Dave
Klatuu - 16 Jul 2007 14:38 GMT
The problem I see is this:
> Private Sub cboClassification_()
There is no event name here.  Where are you expecting this to execute?  I
would suspect it should be in the combo's After Update event.

Also, this is a good place to use a Select Case statememt:

   With Me
       Select Case .cboClassification
           Case "UNCLASS"
               .Con_Num_Class = "U"
           Case "CONFIDENTIAL"
               .Con_Num_Class = "C"
           Case "SECRET"
               .Con_Num_Class = "S"
       End Select
   End With
   End If
End If

Signature

Dave Hargis, Microsoft Access MVP

> New to coding...
>
[quoted text clipped - 19 lines]
>
> Dave
SusanV - 16 Jul 2007 14:39 GMT
What event are you using? Should be the cboClassification's After Update
event. Also be sure in your code to preface cboClassification with Me:

If Me.cboClassification = "UNCLASS" Then
   Me!Con_Num_Class = "U"
Else
   If Me.cboClassification = "CONFIDENTIAL" Then
       Me!Con_Num_Class = "C"
   Else
       If Me.cboClassification = "SECRET" Then
           Me!Con_Num_Class = "S"
       End If
   End If
End If

Give that a try. Also might want to use a SELECT Case statement instead.

Signature

hth,
SusanV

> New to coding...
>
[quoted text clipped - 19 lines]
>
> Dave
Douglas J. Steele - 16 Jul 2007 14:42 GMT
What does "not working" mean? Are you getting an error message? If so, what
is it? Or is it a case that nothing's going into the text box?

Are you certain that cboClassification returns what you think it does? Try
the following:

Private Sub cboClassification_()
 Select Case Me!cboClassification
   Case "UNCLASS"
     Me!Con_Num_Class = "U"
   Case "CONFIDENTIAL"
     Me!Con_Num_Class = "C"
   Case "SECRET"
     Me!Con_Num_Class = "S"
   Case Else
     MsgBox "The combo box is returning " & _
       Me!cboClassification
 End Select
End Sub

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

> New to coding...
>
[quoted text clipped - 19 lines]
>
> Dave
Al Campagna - 16 Jul 2007 14:49 GMT
Dave,
  Try...
> Private Sub cboClassification_AfterUpdate()
>     If cboClassification = "UNCLASS" Then
[quoted text clipped - 5 lines]
>     End If
> End Sub

  You could also use a Select Case Statement to accomplish the same thing.

   BUT... all this is redundant.  If cboClassification is bound to some
field in your table, (say Classification) that would be all you need to
capture.  Having another control to capture the "U" in Unclass, or "C" in
Classified... etc, is redundant.
   Given that you capture "UnClass, you could always calculate and display
the "U" (on the fly) by using an unbound text control with a Control Source
of ...
       = Left(cboClassification, 1)
Signature

hth
   Al Campagna
   Access MVP 2007
   http://home.comcast.net/~cccsolutions/index.html

   "Find a job that you love, and you'll never work a day in your life."

> New to coding...
>
[quoted text clipped - 19 lines]
>
> Dave
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.