代码如下:
 Dim rsTemp As Recordset
    Dim dbTemp As Database
    Dim astr As String
    Dim nam As String
    nam = Label1.Caption
  Set dbTemp = DBEngine(0).OpenDatabase(App.Path + "\db3.mdb", dbOpenSnapshot)
 astr= "select 密码 from password where 开票员=" + nam + ""想让查询出来的密码给变量,可是得出的结果并不是我想要的,不知我哪里错了?请指教。

解决方案 »

  1.   

    我觉得你还没有执行Select命令,是不是还要一条Execute语句呢?
      

  2.   

    追加这些:
    dim rs as recordset
    set rs=db.openrecordset(astr)if rs.recordcount>0 then
     msgbox rs![密码]
    end if
      

  3.   

    astr= "select 密码 from password where 开票员='" + nam + "'"
      

  4.   

    你大概是要验证密码吧?
    你可以先把用户输入的密码存给变量strPWD
    然后:select count(开票员) as couPer from password where 开票员='" + nam + "' and 密码='" & strPWD & "'"
      

  5.   

    if rst.fields("couper")>0 then msgbox "OK"
      

  6.   

    判断有无时,用这个吧
    IF NOT Rs.EOF AND NOT Rs.BOF THEN
       Msgbox "有记录"
    ELSE
       Msgbox "无记录"
    ENDIF