Avatar billede mrosing Novice
09. oktober 2018 - 18:19 Der er 7 kommentarer og
2 løsninger

rs!key=me!Felt virker ikke ved GUID- Access VBA

Jeg har følgende linjer i VBA
dim rs as ADODB.recordset
dim cn as ADODB.connection

set cn=currentProject.connection
set rs= New ADODB.recordset
rs.open "tabelnavn", cn, AdOpenDynamic, adLockPesimisitc

rs.AddNew
rs!KeyCatchSub1=me!lstShrimpSample
rs.update

Jeg får en fejl -2147217887 Multiple Step OLE DB operation generated errors.

rs!KeyCatchSub1 og me!lstShrimpSample er GUID felter.
Jeg har en identisk kode et andet sted med en GUID værdi der skal læses fra en formular ind i en tabel, der er ikke noget problem.
Avatar billede terry Ekspert
09. oktober 2018 - 19:30 #1
well if its working on one form then there is obviously something which is not the same. Double check your code and data types.
Also try debugging to see what lstShrimpSample actually contains before update
Avatar billede mrosing Novice
09. oktober 2018 - 19:45 #2
I have checked what the field lstShrimpSample contains and it is in fact a GUID Key value.

The data types are both GUID.

The only difference that I can find is that the table that I try to write to is in the application that I am writing and not in a linked table.

The application is supposed to have several copies linked to the main database. In each application copy someone will measure some shrimp and then upload them to the main database. Hence the local vs linked tables.
Avatar billede terry Ekspert
09. oktober 2018 - 21:08 #3
Is there any chance of seeing a copy of the dB, or at least the parts which are giving you problems?

ekspertenATsanthell.dk
AT = @
Avatar billede mrosing Novice
09. oktober 2018 - 21:18 #4
Is it possible to send a copy somewhere ?
Avatar billede terry Ekspert
09. oktober 2018 - 21:22 #5
you got my email (zip file please) ;-)
Avatar billede terry Ekspert
09. oktober 2018 - 21:24 #6
main and linked dB too
Avatar billede terry Ekspert
10. oktober 2018 - 13:45 #7
?
Avatar billede mrosing Novice
16. oktober 2018 - 16:00 #8
I work a bit sporadically in the fall because of other work, so I may answer with some delay.
Avatar billede terry Ekspert
19. oktober 2018 - 16:20 #9
solution for other users.
https://docs.microsoft.com/en-us/office/vba/api/access.listbox.boundcolumn

In the listbox lstShrimpSample the column width for the first column was originally > 0 (visible)

This also has an effect on BoundColumn which you can read about in the link above, although it doesn’t explain very well.

So, if the column width is 0, then you can get the value of that column using  EG: Me! lstShrimpSample, but if it is visible (greater than 0)  then you should use the column number EG: Me! lstShrimpSample.Column(0).

So if you change the column width to 0, or use column number .column(0) it should work.
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
Kurser inden for grundlæggende programmering

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