Re: DoCmd.RunSQL
From: JV (JV_at_discussions.microsoft.com)
Date: 07/28/04
- Next message: Marshall Barton: "Re: Calculations in Report"
- Previous message: Ted Allen: "RecordSet shows DOUBLE the actual no. of records"
- In reply to: Douglas J. Steele: "Re: DoCmd.RunSQL"
- Next in thread: Douglas J. Steele: "Re: DoCmd.RunSQL"
- Reply: Douglas J. Steele: "Re: DoCmd.RunSQL"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 28 Jul 2004 07:49:09 -0700
Thanks for the help, Douglas.
It did not allow me to use DAO.Recordset as a data type. So I used recordset as a data type and kept everything else the same. I get an error message now which says Type mismatch. What should I do now?
"Douglas J. Steele" wrote:
> You need to open a recordset, check that there's something in the recordset,
> then retrieve the value from that recordset.
>
> Using DAO, this would be something like:
>
> Private Sub cmd_password_Click()
> On Error GoTo Err_cmd_password_Click
>
> Dim Passw As String
> Dim MasterP As Integer
> Dim rs As DAO.Recordset
>
> Passw = "SELECT tbl_2004_Library.Reference, tbl_2004_Library.rc, " & _
> "tbl_2004_Library.job, tbl_2004_Library.prime, " & _
> "tbl_2004_Library.account, tbl_2004_Library.desc, " & _
> "tbl_2004_Library.us_amt, tbl_2004_Library.MP " & _
> "FROM tbl_2004_Library " & _
> "WHERE tbl_2004_Library.MP=" & MasP
>
> Set rs = CurrentDb().OpenRecordset(Passw)
> If Not rs.BOF And Not rs.EOF Then
> ' You can get the value of the matching fields using
> ' rs!Reference, rs!rc, rs!job, etc.
> Else
> ' No record matches your criteria
> End If
>
> rs.Close
> Set rs = Nothing
>
> Exit_cmd_password_Click:
> Exit Sub
>
> Err_cmd_password_Click:
> MsgBox Err.DESCRIPTION
> Resume Exit_cmd_password_Click
>
> End Sub
>
> Note that the WHERE clause that's being set assumes MP is numeric. If it's
> text, you need to enclose the value in quotes:
>
> "WHERE tbl_2004_Library.MP=" & Chr$(34) & MasP & Chr$(34)
>
> --
> Doug Steele, Microsoft Access MVP
> http://I.Am/DougSteele
> (no e-mails, please!)
>
>
>
- Next message: Marshall Barton: "Re: Calculations in Report"
- Previous message: Ted Allen: "RecordSet shows DOUBLE the actual no. of records"
- In reply to: Douglas J. Steele: "Re: DoCmd.RunSQL"
- Next in thread: Douglas J. Steele: "Re: DoCmd.RunSQL"
- Reply: Douglas J. Steele: "Re: DoCmd.RunSQL"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|