Results 1 to 4 of 4

Thread: What am I doing wrong!

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Australia
    Posts
    69

    Angry

    Hi guys..silly question

    All I want is to assign a text box value to a variable as follows:

    Dim d As Integer

    d = Val(txtBD.Text)

    Keeps telling me the value of d is 0 even if the text field is say 10000.

    What I'm I doing wrong!!!

    Gerard
    Live long and prosper...

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Try:
    Code:
    Dim d As Integer
    d = CInt(Val(Trim(txtBD.Text)))
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Australia
    Posts
    69
    d= CInt(Val(Trim(txtBD.Text)))

    txtBD.text could be say 650

    d still showing me 0
    Live long and prosper...

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2000
    Location
    Australia
    Posts
    69

    More info

    The value of txtBD.text is created as follows

    txtBD.Text = rstStat.Fields("[bd]")

    if I have atextbox that I type a value in I have no trouble assigning this value to a varable.

    The full code is as follows...


    Dim strSQL2 As String
    Dim strSQL3 As String
    Dim varD As Integer
    Dim z1 As Integer
    Dim er2 As Integer
    Dim p1 As Integer
    Dim qq As Integer

    varD = 0
    z1 = 0
    er2 = 0
    p1 = 0
    qq = 0







    Dim db As Database

    Set db = DBEngine.Workspaces(0).OpenDatabase(strDataLoc)


    If Trim(strSQL) = "where" Then
    strSQL = ""
    End If






    If cboWardUnit1.ListIndex = 0 Then
    strSQL2 = "SELECT Sum(TempDatesTbl.BedDays) AS bd FROM TempDatesTbl"
    ElseIf cboWardUnit1.ListIndex = 1 Then
    strSQL2 = "SELECT Sum(TempDatesTbl.BedDays) as bd from TempDatesTbl and " & "Ward = " & cboWard.BoundText
    ElseIf cboWardUnit1.ListIndex = 2 Then
    strSQL2 = "Sum(TempDatesTbl.BedDays) as bd from TempDatesTbl and " & "Unit = " & cboUnit.BoundText
    End If


    Set rstStat = db.OpenRecordset(strSQL2)

    txtBD.Text = rstStat.Fields("[bd]")



    strSQL3 = "SELECT Sum(MROstatsTbl.[organism]) AS org FROM MROstatsTbl " & strSQL

    Set rstStat = db.OpenRecordset(strSQL3, dbOpenDynaset)

    txtE.Text = rstStat.Fields("org")


    If txtBD.Text = 0 Or txtBD.Text = Null Then
    varD = 1000
    Else
    varD = CInt(Val(Trim(txtBD.Text)))

    End If
    Live long and prosper...

Posting Permissions

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



Click Here to Expand Forum to Full Width