本系统是VB+Access做的,是图书管理系统,编译下面一段的时候老是编译错误,
提示“未找到方法或数据成员”,以下是代码:
Private Sub txtReaderID_KeyPress(KeyAscii As Integer)
'判断用户按下回车键并且是否输入读者编号
If KeyAscii = "13" And txtReaderID.Text <> "" Then
'根据输入的读者编号,查找读者姓名
g_strSql = "select * from readerInfo where 读者编号='" & txtReaderID.Text & "'"
Set g_rs = g_db.OpenRecordset(g_strSql) '进行数据库的查询
'判断是否找到
If Not g_rs.EOF Then
txtReaderName.Text = g_rs!读者姓名
txtReaderda.Text = g_rs!办证日期
txtReadertel.Text = g_rs!联系电话
txtReaderadd.Text = g_rs!家庭地址
InitDataGrid (False) '初始化DataGrid控件信息
Else
MsgBox "没有该读者信息!", vbOKOnly, "提示"
txtReaderName.Text = ""
End If
Set g_rs = Nothing
ElseIf KeyAscii = "13" And txtReaderID.Text = "" Then
MsgBox "请先输入读者编号", vbOKOnly, "提示"
End If
End Sub
但是以下代码却能通过
Private Sub txtBookID_KeyPress(KeyAscii As Integer)
'判断用户按下回车键并且是否输入读者编号和书籍编号
If KeyAscii = "13" And txtReaderID.Text <> "" And txtBookID.Text <> "" Then
g_strSql = "select bookInfo.书籍名称,bookInfo.书籍价格,bookInfo.出版社,bookInfo.书籍页码," _
& "bookInfo.是否借出,bookType.书籍类别 from bookInfo,bookType where 书籍编号='" & txtBookID.Text & "'" _
& " and bookInfo.类别代码=bookType.类别代码"
Set g_rs = g_db.OpenRecordset(g_strSql)
If Not g_rs.EOF Then
txtBookName.Text = g_rs!书籍名称
txtBookPrice.Text = g_rs!书籍价格
txtBookLeibie.Text = g_rs!书籍类别
txtBookConcern.Text = g_rs!出版社
txtBookPage.Text = g_rs!书籍页码
If g_rs!是否借出 = True Then
MsgBox "该书已经借出,请选择其它图书!", vbOKOnly, "提示"
cmdLendBook.Enabled = False
Else
cmdLendBook.Enabled = True
End If
Else
MsgBox "没有该书信息!", vbOKOnly, "提示"
txtBookName.Text = ""
txtBookPrice.Text = ""
txtBookLeibie.Text = ""
txtBookConcern.Text = ""
txtBookPage.Text = ""
End If
Set g_rs = Nothing
ElseIf KeyAscii = "13" And txtReaderID.Text = "" Then
MsgBox "请先输入读者编号", vbOKOnly, "提示"
ElseIf KeyAscii = "13" And txtReaderID.Text <> "" And txtBookID.Text = "" Then
MsgBox "请先输入书籍编号", vbOKOnly, "提示"
End If
End Sub
大家请给我指点,谢谢