Vb5 and Access question

Vb5 and Access question

Post by remove-1234hrib.. » Mon, 09 Feb 1998 04:00:00

I have a vb5 app that I am working on  Here a routine I use to populate a
listbox with fields from the access DB

Public Sub cmdList_Click()

WaterList.Clear ' Clear all entries from the Listbox

Set DB = OpenDatabase("c:\mydocu~1\fish.mdb")
Set SNAPPWater = DB.CreateSnapshot("water_quality")

Print SNAPPWater.Fields.Count
While Not SNAPPWater.EOF
Dat$ = SNAPPWater.Fields("DATE")
Tim$ = SNAPPWater.Fields("Time")
Amm$ = SNAPPWater.Fields("Ammonia")
pH$ = SNAPPWater.Fields("ph")
Nitrate$ = SNAPPWater.Fields("Nitrate")
Nitrite$ = SNAPPWater.Fields("Nitrite")
Alk$ = SNAPPWater.Fields("Alkalinity")
Hardness$ = SNAPPWater.Fields("Hardness")
Temp$ = SNAPPWater.Fields("Temperature")

Item$ = Dat$ + "  " + Tim$ + "  " + Amm$ + "       " + pH$ + "         " +
Nitrate$ + "       " + Nitrite$ + "        " + Alk$ + "          " +
Hardness$ + "               " + Temp$

    WaterList.AddItem Item$
    WaterList.ItemData(WaterList.NewIndex) = SNAPPWater.Fields("WaterID")

end sub

On th same form I have  fex txts fields that one can enter in and add to
the access db. What I want to do is if someone clicks on the item in the
list box the text boxes above will show that record.. How can I accomplish
this task?

The following line:

 WaterList.ItemData(WaterList.NewIndex) = SNAPPWater.Fields("WaterID")

stores the WaterID from the db, how can I use this to re-populate the txt
field with the item the person clicked on (so that and edit this text if
they so chose)

I hope I didnt confuse anyone :)

If I did drop me email and I will try and explain better :)



1. VB5-DAO-ACCESS question

I defined a Select query in a MS ACCESS 95 database that uses a vb function
defined in an ACCESS Mocule.
I worte a VB5 app that uses the mdb file. When I executed the query from
the VB5 app using the following syntax

DB.Execute "Insert into tbl select * from qry"

where qry is the query with the VB function, I recieved an error message
stating that the function is not found.

However, when I run the query qry from ACCESS, it runs fine.

Can one execute a query that uses a function defined in an ACCESS Module
from within a VB app? Any special techniques or workarounds..?

I appreciate any answers or comments...

A.M. Alashqur
Senior application consultant

2. How to update tables in a linked database

3. Question: accessing a stored Access query from VB5 app

4. how to make a new system stored procedure?

5. DAO 2.5 to DAO 3.5 and Access 2.0 to Access 97 Answers and Questions (VB5)

6. Sticky notes

7. A few questions about VB5 and Access

8. Question about VB5 with Access 7.0 database

9. Newbie Access/VB5 question...

10. Access 200 & VB5 Question

11. PLEASE HELP - Access Question for my VB5.0 program

12. Questions for VB5 and accessing a SYBASE Database...