Dcount and Dlookup in vb6 (1 Viewer)

ram_son

Registered User.
Local time
Today, 15:52
Joined
May 14, 2006
Messages
11
I am working on an application that uses an access db and was having a problem where randomizing kept starting at the same point all the time. On the Access forum they helped me get randomizing to work but through using Dlookup and Dcount as follows:

Randomize
'====================================
Dim iCount As Integer
Dim j As Integer

iCount = DCount("*", "Table")
j = Int(iCount * Rnd()) + 1
ca = DLookup("[Answer]", "
", "[IDQuestion]=" & j)
'====================================

Now after getting rid of Rnd() in the first query, the form can start with a random answer in Access.

DCount() and DLookup() are Access specific. In VB6, you can open recordsets with Select statements instead. If the number of records in the table is fixed, you can hard code iCount with the number.

Hopefully you can adapt the code in VB.


The problem is I couldn't translate this into vb6 code. I found a couple of articles and code posting dealing with adapting Dlookup and Dcount for vb6..but when I run them I get type mismatch on "Title" in the Dlookup procedure.

Anyone can help me adapt the code in vb6?

Thanks in advance
Ram_son
 

Users who are viewing this thread

Top Bottom