Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Posts
    292

    Unanswered: Variable help....

    I have a form which searches for records.. you put in a number in the field and hit a button and the record displays in the appropriate fields..

    I recently made a change to one of my fields from a TEXT to a NUMBER data type.. once i did that.. when i hit my button to pull data.. nothing happens..

    The field as decribed is called ControlNo ... Did I miss something ? Heres the code behind my button..


    Private Sub Command13_Click()
    Dim db As Database
    Dim rst As Recordset
    Dim qdf As QueryDef
    Dim Control As Integer


    Set db = CurrentDb()
    Set qdf = db.QueryDefs("qryQRrecord")
    ControlNo.SetFocus
    Control = ControlNo.Text


    On Error GoTo HandleFormLoadError

    qdf.SQL = "SELECT * FROM tblQR " & _
    "WHERE (((tblQR.ControlNo) = '" & Control & "'))"
    Set rst = qdf.OpenRecordset(dbOpenDynaset)


    If rst.BOF And rst.EOF Then
    rst.AddNew
    MsgBox "No Matched Records - Try Again!"
    rst!Control = Control
    rst!strProject = "*"
    rst!strArea = "*"
    rst!strReference = "*"
    rst!EPO = "*"
    rst!Site = "*"
    'rst!System = "*"
    rst!strDate = "*"
    rst.Update
    Else
    strProject.SetFocus
    strProject.Text = Nz(rst!strProject, " ")
    strArea.SetFocus
    strArea.Text = Nz(rst!strArea, " ")
    strReference.SetFocus
    strReference.Text = Nz(rst!strReference, " ")
    EPO.SetFocus
    EPO.Text = Nz(rst!EPO, " ")
    Site.SetFocus
    Site.Text = Nz(rst!Site, " ")
    'System.SetFocus
    'System.Text = Nz(rst!System, " ")
    strDate.SetFocus
    strDate.Text = Nz(rst!strDate, " ")
    End If

    HandleFormLoadError:
    Dim strError As String
    Select Case Err.Number
    Case 3265
    strError = "Try Again"
    If strError = "" Then
    MsgBox "You must Enter a Value"
    End If
    End Select
    End Sub


    thanks

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1

    Re: Variable help....

    qdf.SQL = "SELECT * FROM tblQR " & _
    "WHERE (((tblQR.ControlNo) = " & Control & "))"
    Set rst = qdf.OpenRecordset(dbOpenDynaset)


    Try that. By using the ' you are explicitly defining the paramter as a string, you need access to recognize it as a number. So, removing the quotes should do the trick.

  3. #3
    Join Date
    Jul 2003
    Posts
    292
    thanks so much..

    Something that i did not know..

Posting Permissions

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