Avatar billede dm013 Nybegynder
20. oktober 2003 - 12:29 Der er 6 kommentarer og
1 løsning

Access Frontend mod SQL Server 2000

Jeg har et problem med en Dlookup, det virker godt nok hvis det databaseprojektet åbnes i OfficeXP, men i Office2000 fejler den:
'If Not IsNull(DLookup("id", "dbo.daglig_afhentning", "fid=" & CurID & " And i_dato<='" & d & "' And s_dato>='" & d & "'")) Then
'CurdagligID = DLookup("id", "dbo.daglig_afhentning", "fid=" & CurID & " And i_dato<='" & d & "' And s_dato>='" & d & "'")
'End If

fejlbeskrivelsen i Office2000 lyder:

Der opstod et problem ved adgang til en egenskab eller metode i OLE-objektet

Anyone got a clue what this is all about?

/dm013
Avatar billede terry Ekspert
20. oktober 2003 - 18:32 #1
All I can suggest is that you try changing your dlookup slightly to see if it helps. There are a number of things which dont seem to work as expected with projects in Access 2000

I also see you are making the same dlookup twice

Try
dim MyVar as Variant
MyVar = DLookup("id", "daglig_afhentning", "fid=" & CurID & " And i_dato<='" & d & "' And s_dato>='" & d & "'")

If Not IsNull(MyVar) Then 'CurdagligID = MyVar
Avatar billede terry Ekspert
20. oktober 2003 - 18:34 #2
also make sure that the criteria part of the dlookup is valid (d is a date which does contain a value for example.)
Avatar billede dm013 Nybegynder
21. oktober 2003 - 07:03 #3
Hi Terry,

I checked that d contains a value, and it does. I also checked that the dateformat's was similar, they are. I'll try out your surgestion on myvar today. tuesday that is.
Avatar billede dm013 Nybegynder
21. oktober 2003 - 08:15 #4
It is this part that makes the trouble:

& " And i_dato<='" & d & "' And s_dato>='" & d & "'"
Avatar billede terry Ekspert
21. oktober 2003 - 19:39 #5
OK, here is a suggestion.
In your code declare a variable and make a line of code where you intialize it.

Then place a breakpoint til just after the line of code.


Dim sWhere as string

sWhere = "fid=" & CurID & " And i_dato<='" & d & "' And s_dato>='" & d & "'"

In the debug window (Ctrl+G) you can now
write
?"SELECT id FROM daglig_afhentning WHERE " & sWhere

now you have the actual SQL you can in the query analayser or in a VIEW directly in your Access db.

I have a feeling you may need to format your date yyyy-mm-dd
Avatar billede dm013 Nybegynder
22. oktober 2003 - 08:58 #6
Returns: OBject doesn't support this Property or Method.
if i instead, puts it into a msgbox all the values returned are as I expect them to be.
Avatar billede dm013 Nybegynder
22. oktober 2003 - 11:31 #7
It was an date handling issue, thanks for your effort.
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
Computerworld tilbyder specialiserede kurser i database-management

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