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