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
Printable View
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
Try:
Code:Dim d As Integer
d = CInt(Val(Trim(txtBD.Text)))
d= CInt(Val(Trim(txtBD.Text)))
txtBD.text could be say 650
d still showing me 0
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