Ask a Question related to Microsoft Access, Design and Development.

  1. #1

    Default Filling fields

    I have a table named CODES that contains the following
    fields:
    MainCode field length = 8
    Hex1 field length = 2
    Hex2 " " "
    Hex3 " " "
    Hex4 " " "

    I would like to enter 8 digits into the "MainCode" field
    and have the form automatically take the first 2 digits
    and enter them in "Hex1", then the next 2 digits
    into "Hex2" and so forth.
    Example:
    MainCode 12345678
    Hex1 12
    Hex2 34
    Hex3 56
    Hex4 78

    I can get it to enter the first 2 digits into Hex1 with
    this code:

    Private Sub MainCode_AfterUpdate()

    Dim txtCode As String
    Dim Code1 As String

    txtCode = Forms!keys!MainCode.Text
    Forms!keys!MainCode.SetFocus
    Forms!keys!hex1.SetFocus
    Code1 = Forms!keys!hex1.Text
    Code1 = UCase(Left(MainCode, 2))

    If Forms!keys!hex1.Text = "" Then
    Forms!keys!hex1 = Code1

    End If

    End Sub

    Can someone help me?
    Thanks!


    Mike Geoghegan Guest

  2. Similar Questions and Discussions

    1. dropdownlist not filling up?
      Hi, I have a dropdownlist that contains should contain several values from the database, I fill it up in de page_load() with this code (at the...
    2. filling pie
      Hello all, I want to make a pie chart that would slowly with time (around 50-100 frames) fill with a blue color. What is the best way to do it?...
    3. filling in forms.
      Is it possible to scan in a completed form, save as a pdf file and then edit the entries?
    4. #26351 [Opn->Bgs]: Incorrect handling of Null Fields/Numerical Fields with '0'
      ID: 26351 Updated by: iliaa@php.net Reported By: jabberwocky at ibplanet dot com -Status: Open +Status: ...
    5. #26351 [NEW]: Incorrect handling of Null Fields/Numerical Fields with '0'
      From: jabberwocky at ibplanet dot com Operating system: Any PHP version: 4.3.4 PHP Bug Type: MSSQL related Bug description: ...
  3. #2

    Default Re: Filling fields

    Mike,
    Since the MainCode always contains the information needed to fill in
    Hex1-Hex4, there's no need to have those fields in your table. They can
    always be "re-derived" the values "on the fly" from MainCode in any
    subsequent form, query, report, etc.
    An example is... if I store Price and Qty, I don't need to store
    LineItemCost (Price*Qty), since I can always recalc it whenever it's needed.
    In your case, 4 "unbound" calculated fields will display the Hex1-4
    values.
    The Hex1 ControlSource would be...
    = Left(MainCode,2)
    The Hex2 ControlSource would be...
    = Mid(MainCode,3,2)
    The Hex3 ControlSource would be...
    = Mid(MainCode,5,2)
    And Hex4...
    = Right(MainCode,2)
    --
    HTH
    Al Campagna
    Candia Computer Consulting
    Candia, NH

    "Mike Geoghegan" <mgeoghegan@mayinstitute.org> wrote in message
    news:28d701c33f4d$d289e530$a601280a@phx.gbl...
    > I have a table named CODES that contains the following
    > fields:
    > MainCode field length = 8
    > Hex1 field length = 2
    > Hex2 " " "
    > Hex3 " " "
    > Hex4 " " "
    >
    > I would like to enter 8 digits into the "MainCode" field
    > and have the form automatically take the first 2 digits
    > and enter them in "Hex1", then the next 2 digits
    > into "Hex2" and so forth.
    > Example:
    > MainCode 12345678
    > Hex1 12
    > Hex2 34
    > Hex3 56
    > Hex4 78
    >
    > I can get it to enter the first 2 digits into Hex1 with
    > this code:
    >
    > Private Sub MainCode_AfterUpdate()
    >
    > Dim txtCode As String
    > Dim Code1 As String
    >
    > txtCode = Forms!keys!MainCode.Text
    > Forms!keys!MainCode.SetFocus
    > Forms!keys!hex1.SetFocus
    > Code1 = Forms!keys!hex1.Text
    > Code1 = UCase(Left(MainCode, 2))
    >
    > If Forms!keys!hex1.Text = "" Then
    > Forms!keys!hex1 = Code1
    >
    > End If
    >
    > End Sub
    >
    > Can someone help me?
    > Thanks!
    >
    >

    ---
    Outgoing mail is certified by AVG 6.0 as Virus Free.
    Checked by AVG anti-virus system ([url]http://www.grisoft.com[/url]).
    Version: 6.0.493 / Virus Database: 292 - Release Date: 6/25/03


    Al Campagna Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139