Avatar billede dm013 Nybegynder
29. maj 2003 - 11:04 Der er 12 kommentarer og
1 løsning

Function virker ikke mere

Function GetMachineName() As String
'Returns the computername
Dim lngLen As Long, lngX As Long
Dim strCompName As String
    lngLen = 16
    strCompName = String$(lngLen, 0)
    lngX = apiGetComputerName(strCompName, lngLen)
    If lngX <> 0 Then
        GetMachineName = left$(strCompName, lngLen)
    Else
        GetMachineName = ""
    End If
End Function

HVorfor får jeg pludselig fejl på 'left$', jeg har en anden database hvor denne funktion virker fint, jeg har tjekket referencerne.
fejlen:
"Compile error:
Type-declaration character does not match declared data type"
Avatar billede terry Ekspert
29. maj 2003 - 11:20 #1
this doesnt look right.

lngX As Long
Then
lngX = apiGetComputerName(strCompName, lngLen)

What does apiGetComputerName return?

You can also try left(strCompName, lngLen)
(without $)
Avatar billede terry Ekspert
29. maj 2003 - 11:25 #2
OK, had another look and teh code seems OK, but I think you can remove $ from left still.

Try compiling the program. Quit eoften IF you have a MISSING reference then it will give strange side effects such as this. IF you get an error when compiling then this should give an indication to the problem.
Avatar billede terry Ekspert
29. maj 2003 - 11:25 #3
.
Avatar billede dm013 Nybegynder
29. maj 2003 - 11:35 #4
i have narrowed it down a bit, it isn't the code displayed here that is triggin the error, it seems to my error handling:
NOT working:
Function report_error(mask, LOgin, Form, Err, felt)
Dim CONN As ADODB.Connection
Set CONN = CurrentProject.Connection
CONN.Execute "exec sp_Error  " & "'" & Form & "'," & "'" & Err & "'," & "'" & mask & "'," & "'" & LOgin & "'," & "'" & felt & "'"
Set CONN = Nothing
End Function

Working:
Function report_error(mask, LOgin, Form, Err)
Dim CONN As ADODB.Connection
Set CONN = CurrentProject.Connection
CONN.Execute "exec sp_Error  " & "'" & mask & "'," & "'" & LOgin & "'," & "'" & Form & "'," & "'" & Err & "'"
Set CONN = Nothing
End Function
Avatar billede terry Ekspert
29. maj 2003 - 11:42 #5
Function report_error(mask, LOgin, Form, Err)

Its an idea to declare the data types! ALSO "form" should NOT be used as a variable name as it is alreday used by Access, and Err is too

Function report_error(mask as string, LOgin as string ,YourForm as  Form, YourErr as ?)

If you place

Option Explicit

at the top of each module and code in the form then you will get an error if a variable is not declared.
Avatar billede terry Ekspert
29. maj 2003 - 11:42 #6
IF you think it is this code the comment it out and see if it works
Avatar billede dm013 Nybegynder
29. maj 2003 - 11:46 #7
that was how i found out
Avatar billede terry Ekspert
29. maj 2003 - 11:51 #8
OK, so correct the things I mentioned and go from there, one step at a time :o)

I would look at ALL your variable names! Login is more than likley reserved too
Avatar billede dm013 Nybegynder
29. maj 2003 - 11:56 #9
I will do just that and thanx
Avatar billede terry Ekspert
29. maj 2003 - 12:16 #10
selv thanks :o)
Avatar billede dm013 Nybegynder
29. maj 2003 - 12:58 #11
just for your information,

if I name a function left, it has an impact on everything that has to do with left..... strange Hu... :O)
NOT
Avatar billede terry Ekspert
29. maj 2003 - 13:01 #12
More than likely, left is a VBA function alreday so when you have your own left function which one gets performed?
Avatar billede dm013 Nybegynder
29. maj 2003 - 13:06 #13
I'm glad I don't have a loaded gun in the house, Chances are that I would have issued a death penalty on myself. *lol*
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