Results 1 to 4 of 4
  1. #1
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231

    Populate Text Field Based on Another Numerical Field

    I have a text field that holds three types of code letters: c, p or t. Right now, my client manual updates this field based on if there are numbers (sizes of material) in a numerical field.



    Is there any way that these three letters could be manually populated if there were numbers(sizes) present is this numerical field?

    Is there anyway this can be done in the control source of the text field?

    CementCarver

  2. #2
    CementCarver's Avatar
    CementCarver is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Feb 2013
    Location
    Canada
    Posts
    231
    I meant to say "could this text field be automatically populate" if a number existed in the size field.

    CC

  3. #3
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Perhaps with an Update Query?
    Just have it use criteria in your number field, something like:
    Code:
    > 0

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Are you trying to do this retroactively, i.e. you have existing Records and you want to assign these values in the Text Field if the Numerical Field has Values? If so, an Update Query is, indeed, the way to go.

    If, however, you want the Text Field populated if/when a Value is entered in the Numerical Field, something in the Numerical Field Control's AfterUpdate event would be in order.

    Code:
    Private Sub SizeField_AfterUpdate()
      
     Select Case Me.SizeField
     
       Case Is = 1, 3
         Me.TextField = "c"
     
       Case 5 To 10
         Me.TextField = "p"
     
       Case Is > 10
         Me.TextField = "t"
     
       Case Else
         Me.TextField = Null
     
      End Select
    
    End Sub


    You haven't given specific details on the relationships between the numbers and letters, so I've given you a couple of different ways to program that.

    If SizeField is 1 or 3, then the TextField is 'c'
    If SizeField is anywhere from 5 to 10, then the TextField is 'p'
    If SizeField is greater than 10 then the TextField is 't'
    If SizeField is anything not covered, above, such as 2, or if a number had been entered and then was deleted, then the TextField is 'Null' or empty.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 1
    Last Post: 05-24-2013, 02:44 AM
  2. Sum numerical filed based on other field
    By BorisGomel in forum Access
    Replies: 0
    Last Post: 07-11-2012, 09:54 AM
  3. Replies: 3
    Last Post: 10-03-2011, 02:33 PM
  4. Selecting a corresponding table field based on text field.
    By michaeljohnh in forum Programming
    Replies: 5
    Last Post: 10-08-2010, 10:33 AM
  5. Replies: 2
    Last Post: 05-05-2010, 02:52 PM

Tags for this Thread

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