Avatar billede 44nato44 Nybegynder
15. august 2009 - 13:33 Der er 6 kommentarer

Getrows henter kun en række

Hej

Jeg har nedenstående kode som henter et recordset fra en db og smider det i getrows. Mit problem er at den kun henter den første række og ikke hele tabellen.

Jeg har arbejdet lidt med asp og der skal man bare sige ubound(arraynavnet), og så har man det.. er det ikke lige så nemt her ?

koden :

Dim db As DAO.Database
Dim tblRstApp As DAO.Recordset
Dim tblRstAppSupTbl As DAO.Recordset
Dim AppSubTbl as Variant
Dim i

Set db = CurrentDb()

  Set tblRstAppSupTbl = db.OpenRecordset("TBL_AppSupTbl", dbOpenDynaset)


AppSubTbl = tblRstAppSupTbl.GetRows()

tblRstApp.FindFirst "ApproverID =" & varApproverID
 
Me.txtSubmitter.Value = tblRstApp("Submitter")

MsgBox "Ubound-" & UBound(AppSubTbl, 2) & "-" & AppSubTbl(1, i) ' Viser 0 - og først værdi fra tabellen

For i = 0 To UBound(AppSubTbl, 2)
    If tblRstApp("DestTable") = AppSubTbl(1, i) Then
        Me.txtDestTable = AppSubTbl(2, i)
        Exit For
    End If
Next
Avatar billede terry Ekspert
15. august 2009 - 13:49 #1
Havent looked closely at your code. GetRows puts the columns in the first dimension of the array and rows in the second

Ubound(AppSubTbl,1) will show you how many columns you have
and
Ubound(AppSubTbl,2) the number of rows.
Avatar billede 44nato44 Nybegynder
15. august 2009 - 13:56 #2
That is what I did, if you look at UBound(AppSubTbl, 2)

For i = 0 To UBound(AppSubTbl, 2)
    If tblRstApp("DestTable") = AppSubTbl(1, i) Then
        Me.txtDestTable = AppSubTbl(2, i)
        Exit For
    End If
Next

So it should work right ?
Avatar billede terry Ekspert
15. august 2009 - 14:25 #3
I cant check that your code is correct as I dont have your data.

What do you get if you use?

MsgBox Ubound(AppSubTbl,1) & " " Ubound(AppSubTbl,2)
Avatar billede 44nato44 Nybegynder
16. august 2009 - 16:29 #4
,1 gives 2
,2 gives 0

I changed a bit

AppSubTbl = tblRstAppSupTbl.GetRows(tblRstAppSupTbl.RecordCount)

MsgBox UBound(AppSubTbl, 1) & "-" & UBound(AppSubTbl, 2) & "-" & UBound(AppSubTbl) & "-" & tblRstAppSupTbl.RecordCount

It gives this - 2-0-2-4

My table has 3 columns and 4 entries

Hope you can help
Avatar billede terry Ekspert
16. august 2009 - 17:34 #5
is it possible for you to send me a copy of your DB?

ekspertenATsanthell.dk

AT?@
Avatar billede 44nato44 Nybegynder
16. august 2009 - 19:27 #6
Cheers Terry

I have send you the DB
Avatar billede Ny bruger Nybegynder

Din løsning...

Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.

Loading billede Opret Preview
Kategori
Dyk ned i databasernes verden på et af vores praksisnære Access-kurser

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester