Results 1 to 2 of 2
  1. #1
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262

    Cool Splitting a number field across 4 text boxes

    Hi

    I am trying to build a report based on an existing form I use, i have the layout built already, however I have encountered a slight issue. I have a field [SNOW] which is a number between 1 and 9999 which normally goes in 4 seperate boxes on the form, so I have put 4 text boxes in and the following vb code to assign the numbers individually.

    However despite there being records and [SNOW] being a required field with a number in i get a

    Run-Time error '2427':
    You entered an expression that has no value

    which highlights the "If [SNOW] >= 1000 And [SNOW] < 2000 Then" line below

    Thanks for looking! Thanks even more if you can save any of my hair!
    Code:
     
    Private Sub Report_Open(Cancel As Integer)
    Dim snowhundreds As Integer
    Dim snowtens As Integer
    Dim snowsingle As Integer
    If IsNull([SNOW]) Then
    [SNOW] = 0
    End If
        If [SNOW] >= 1000 And [SNOW] < 2000 Then
        Text689 = 1
        ElseIf [SNOW] >= 2000 And [SNOW] < 3000 Then
        Text689 = 2
        ElseIf [SNOW] >= 3000 And [SNOW] < 4000 Then
        Text689 = 3
        ElseIf [SNOW] >= 4000 And [SNOW] < 5000 Then
        Text689 = 4
        ElseIf [SNOW] >= 5000 And [SNOW] < 6000 Then
        Text689 = 5
        ElseIf [SNOW] >= 6000 And [SNOW] < 7000 Then
        Text689 = 6
        ElseIf [SNOW] >= 7000 And [SNOW] < 8000 Then
        Text689 = 7
        ElseIf [SNOW] >= 8000 And [SNOW] < 9000 Then
        Text689 = 8
        ElseIf [SNOW] >= 9000 And [SNOW] < 10000 Then
        Text689 = 9
        Else
        Text689 = 0
        End If
    snowhundreds = [SNOW] - ([Text689] * 1000)
        If snowhundreds >= 100 And snowhundreds < 200 Then
        Text691 = 1
        ElseIf snowhundreds >= 200 And snowhundreds < 300 Then
        Text691 = 2
        ElseIf snowhundreds >= 300 And snowhundreds < 400 Then
        Text691 = 3
        ElseIf snowhundreds >= 400 And snowhundreds < 500 Then
        Text691 = 4
        ElseIf snowhundreds >= 500 And snowhundreds < 600 Then
        Text691 = 5
        ElseIf snowhundreds >= 600 And snowhundreds < 700 Then
        Text691 = 6
        ElseIf snowhundreds >= 700 And snowhundreds < 800 Then
        Text691 = 7
        ElseIf snowhundreds >= 800 And snowhundreds < 900 Then
        Text691 = 8
        ElseIf snowhundreds >= 900 And snowhundreds < 1000 Then
        Text691 = 9
        Else
        Text691 = 0
        End If
    snowtens = [SNOW] - (([Text689] * 1000) + (Text691 * 100))
        If snowtens >= 10 And snowtens < 20 Then
        Text691 = 1
        ElseIf snowtens >= 20 And snowtens < 30 Then
        Text692 = 2
        ElseIf snowtens >= 30 And snowtens < 40 Then
        Text692 = 3
        ElseIf snowtens >= 40 And snowtens < 50 Then
        Text692 = 4
        ElseIf snowtens >= 50 And snowtens < 60 Then
        Text692 = 5
        ElseIf snowtens >= 60 And snowtens < 70 Then
        Text692 = 6
        ElseIf snowtens >= 70 And snowtens < 80 Then
        Text692 = 7
        ElseIf snowtens >= 80 And snowtens < 90 Then
        Text692 = 8
        ElseIf snowtens >= 90 And snowtens < 100 Then
        Text692 = 9
        Else
        Text692 = 0
        End If
    snowsingle = [SNOW] - ((Text689 * 1000) + (Text691 * 100) + (Text692 * 10))
    Text693 = snowsingle
    End Sub


  2. #2
    R_Badger is offline Knows a few tricks
    Windows XP Access 2003
    Join Date
    Feb 2012
    Location
    Suffolk, UK
    Posts
    262
    Well once again a little while on a different job and a coffee solves the issue:

    I had the sub on_open event whereas I really want it on_print! (on load it runs the sub before the data is loaded!)

    Thanks for looking!

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

Similar Threads

  1. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Convert number to fixed length text field
    By tpcervelo in forum Queries
    Replies: 1
    Last Post: 08-02-2010, 07:26 PM
  3. Field switching from Number format to Text
    By COforlife in forum Queries
    Replies: 1
    Last Post: 11-10-2009, 03:23 PM
  4. Replies: 1
    Last Post: 10-09-2008, 04:48 AM
  5. Concatenate two fields (text & number) for key field
    By Larry Elfenbein in forum Forms
    Replies: 2
    Last Post: 11-10-2005, 07:45 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