I need help with Visual Basic
I am trying to build a program in which the user types a question into a text box. Then the program looks for that question in a database (access database to be specific) and returns the appropriate answer from the database. I already started and did some coding. I already added the Microsoft DAO 3.6 object library as required. The code is as below:
Dim dbMyDB As Database Dim rsMyRS As DAO.Recordset Private Sub Form_Load() Set dbMyDB = OpenDatabase("QA.mdb") Set rsMyRS = dbMyDB.OpenRecordset("QADB", dbOpenDynaset) End Sub Private Sub cmdGiveAnswer_Click() rsMyRS.FindFirst "Qes=" & Str(txtQuestion.text) 'this is supposed to search the database for the text in the textbox; txtQuestion. Qes is the field name of the column in which the questions are stored, in the database lblAnswer.Caption = rsMyRS!Answer 'Answer is the name of the field in which the answers are stored. End Sub
When I run the app and as a trial, if I type the text "C" into the text box, I get the following error:
Run-time error '3070':
The Microsoft Jet database engine does not recognize 'C' as a valid field name or expression.
Please tell me what I'm doing wrong!!!
This is just the base idea for the program. What I actually mean to do is this. Every time a person asks a question from the program, it looks up that text and give the answer. If it can't find that text in the database, then it asks the user for an appropriate answer and save both the new question and answer in the database. As more people use the program, the database gets bigger, making the program more "smarter"
All help in helping me to try and make a complete version of this program will be appreciated. Thanks to all of you in advance