I did an example of a test in access 2003 to load some questions from a table but i want to do it in access 2000 but the way it is done in access 2003 is like this: - Private Sub LoadQuestion()
-
Dim NextQuestionID As Long
-
QuestionText = ""
-
ClearAnswerList
-
NextQuestionID = Nz(DMin("QuestionID", "QuestionT", "QuestionID > " & QuestionID))
-
If NextQuestionID = 0 Then
-
QuestionText = "Test Is Complete"
-
Exit Sub
-
End If
-
QuestionID = NextQuestionID
-
QuestionText = DLookup("QuestionText", "QuestionT", "QuestionID=" & QuestionID)
-
-
Dim db As Database
-
Dim rs As Recordset
-
Set db = CurrentDb
-
-
Set rs = db.OpenRecordset("SELECT * FROM AnswerT WHERE QuestionID =" & QuestionID)
-
While Not rs.EOF
-
AnswerList.AddItem (rs!AnswerID & ";" & rs!AnswerText)
-
rs.MoveNext
-
Wend
-
-
rs.Close
-
db.Close
-
Set rs = Nothing
-
Set db = Nothing
-
End Sub
but the problem is in access 2003 there is an "AddItem" and in access 2000 there isn't so how can i convert this code to use in access 2000? instead of access 2003. I cant figure it out
lee123
9 6222
Incorporate the following code into your own wherever appropriate, keeping in mind that this approach is for a limited number of Values that do not change. - Dim db As DAO.Database
-
Dim rs As DAO.Recordset
-
Dim lst As ListBox
-
-
Set lst = Me![AnswerList]
-
-
'Set up the Listbox correctly, if it isn't already
-
lst.RowSourceType = "Value List"
-
lst.ColumnCount = 2
-
lst.BoundColumn = 1
-
lst.ColumnWidths = "0 in;2 in"
-
-
Set db = CurrentDb
-
-
Set rs = db.OpenRecordset("SELECT * FROM AnswerT WHERE QuestionID =" & QuestionID)
-
-
Do While Not rs.EOF
-
strBuild = strBuild & rs!AnswerID & ";" & rs!AnswerText & ";"
-
rs.MoveNext
-
Loop
-
-
lst.RowSource = Left$(strBuild, Len(strBuild) - 1)
well everthing is working but now i am getting an error from a button code that goes to the next question why is that. - Private Sub Command9_Click() ' this is to move to the next question
-
-
Dim db As Database
-
Dim rs As Recordset
-
-
rs.AddNew
-
rs!StudentID = StudentID
-
rs!QuestionID = QuestionID
-
rs!answerid = AnswerList
-
rs.Update
-
-
Set db = CurrentDb
-
Set rs = db.OpenRecordset("ResponseT")
-
rs.Close
-
db.Close
-
Set rs = Nothing
-
Set db = Nothing
-
-
LoadQuestion
-
-
End Sub
the error is pointing to the "rs.AddNew" and the error says "Object variable or with block variable not set".
well you know what here is the whole entire code so it will make sense to you - Private Sub Command8_Click()
-
If IsNull(StudentID) Then
-
MsgBox "Must First Select A Name To Take The Test", , "Hello!"
-
DoCmd.GoToControl "Studentid"
-
StudentID.Dropdown
-
Exit Sub
-
End If
-
StudentID.Enabled = False
-
DoCmd.GoToControl "Answerlist"
-
Command8.Enabled = False
-
QuestionID = 0
-
LoadQuestion
-
End Sub
-
Private Sub ClearAnswerList()
-
Dim x
-
For x = 0 To AnswerList.ListCount - 1
-
AnswerList.ListIndex = ""
-
Next x
-
End Sub
-
Private Sub LoadQuestion()
-
Dim NextQuestionID As Long
-
QuestionText = ""
-
ClearAnswerList
-
NextQuestionID = Nz(DMin("QuestionID", "QuestionT", "QuestionID > " & QuestionID))
-
If NextQuestionID = 0 Then
-
QuestionText = "Test Is Complete"
-
Exit Sub
-
End If
-
QuestionID = NextQuestionID
-
QuestionText = DLookup("QuestionText", "QuestionT", "QuestionID=" & QuestionID)
-
-
Dim db As DAO.Database
-
Dim rs As DAO.Recordset
-
Dim lst As ListBox
-
-
Set lst = Me![AnswerList]
-
-
'Set up the Listbox correctly, if it isn't already
-
lst.RowSourceType = "Value List"
-
lst.ColumnCount = 2
-
lst.BoundColumn = 1
-
lst.ColumnWidths = "0 in;2 in"
-
-
Set db = CurrentDb
-
-
Set rs = db.OpenRecordset("SELECT * FROM AnswerT WHERE QuestionID =" & QuestionID)
-
-
Do While Not rs.EOF
-
strBuild = strBuild & rs!answerid & ";" & rs!AnswerText & ";"
-
rs.MoveNext
-
Loop
-
-
lst.RowSource = Left$(strBuild, Len(strBuild) - 1)
-
-
-
End Sub
-
Private Sub Command9_Click() ' this is to move to the next question
-
-
Dim db As Database
-
Dim rs As Recordset
-
-
rs.AddNew
-
rs!StudentID = StudentID
-
rs!QuestionID = QuestionID
-
rs!answerid = AnswerList
-
rs.Update
-
-
Set db = CurrentDb
-
Set rs = db.OpenRecordset("ResponseT")
-
rs.Close
-
db.Close
-
Set rs = Nothing
-
Set db = Nothing
-
-
LoadQuestion
-
-
End Sub
lee123
- rs is not defined and muse be recreated or Declared as a Form Level Variable and not previously closed.
- Where are you pulling StudentID and QuestionID from, the List Box?
from the response table i have in the response table these are the fields:
ResponseID Autonumber
StudentID Number
QuestionID Number
AnswerID Number
like i said this is from an access 2003 database program i made sometime ago but since i dont have access 2003 anymore and have access 2000 pre i wanted to make it an excutable because i have the developers kit for this
there are three tables
Question Table
Response Table
Answer Table
Student Table
I did know how hard it would be to do this in Access 2000 but i thought i would ask to see if it can be done without changing the code alot But i see Access 2003 is totally Different in so many ways.
lee123
Access 2003 is totally Different in so many ways.
Aside from the missing AddItem Method in Access2000, the rest of the code should have no difficulty executing. Some of the code does not make any sense to me, if you wish to Upload the Database, I'll take a closer look at it.
ok well i'll try to upload this ok
lee123
Have the Attachment and will look it over in the next couple of days.
I've created, at least what I feel, is a good starting point for you. Simply Download the Attachment, and should you have any questions, please feel free to ask. I do not think that it is the most efficient logic in this case, but I conformed to your code as much as possible. P.S. - Keep in mind that this Algorithm requires that the Questions are numbered Sequentially ([QuestionID]) starting at 1 with no gaps in between. Break this conformity, and you'll run into problems. Open qryResponses to obtaing a better Viewpoint on the Results Table.
Thank You for fixing this i have tried it out and it cool...
lee123
Sign in to post your reply or Sign up for a free account.
Similar topics
by: R.Wieser |
last post by:
Hello All,
I'm trying to get a "Virtual Listbox" to work. I've currently got a form,
and used CreateWindowExA to create a ListBox with the LBS_OWNERDRAWFIXED and
LBS_NODATA flags on it. I've...
|
by: Kin®sole |
last post by:
Hi
I am trying to add two variables to a list box and keep everything in line.I
get the result below
Gaz £2000
Jimmy £3000
fred £4000
but would like to get this result
|
by: mibispam |
last post by:
Hallo,
kann mir vielleicht jemand erklären, wieso ich neue Einträge in eine
Listbox nicht per MeineListbox.additem hinzufügen kann?? Ich bekomme
da immer wieder einen Laufzeitfehler. In...
|
by: Alan Lane |
last post by:
Hello world:
I have a ListBox that I fill as a ValueList from a SQL query. The SQL looks
like:
SELECT Format(COST,"$#,000") As ItemCost FROM tblPricing ...
I put semicolons between each...
|
by: andrew.panin |
last post by:
Hi there!
I've got a trouble with these things. What's going on?
1ST STEP: we have ListBox item. Let's call it ListBox1.
We're adding four values to it using AddItem method:...
|
by: serviceman via AccessMonster.com |
last post by:
Hi again gang...
I have downloaded a great little list box select form from Stephen Lebans
that i would like to use in my student email project. The "available" object
is populated thus:
Private...
|
by: Selesti |
last post by:
I've created a form dialog box with several checkboxes to determine which offices to include in a sales report. However, I'm getting an "Object doesn't support this property or method" error from MS...
|
by: ML |
last post by:
I have used Allen Brown's technique for filling a listbox on a form with the
names of files in a certain disc folder.
It works well.
I am now giving the user the option to print the form...
|
by: Sunray |
last post by:
I have a form called the sales form and i have 2 sets of listboxes
So what happens is. i add items form the bottom set of list boxes which are bound to a data base to the top set of list boxes which...
|
by: risk32 |
last post by:
Hello.
I am having a problem with Excel VB. I'm trying to use the value of items in a listbox to manipulate a caption to a label. Any suggestions? I haven't tried to use index, and frankly I don't...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |