Whats wrong here?

Ankarn

Registered User.
Local time
Yesterday, 17:43
Joined
Jul 4, 2008
Messages
81
Code:
Private Sub Kommando23_Click()
Dim strSql As String
Dim A As Variant
Dim B As Variant
Dim C As Variant

LevNavn = Me.LevNavn
LevAtt = Me.LevAtt
LevAdr = Me.LevAdr
LevSted = Me.LevSted
FakNavn = Me.FakNavn
FakAtt = Me.FakAtt
FakAdr = Me.FakAdr
FakSted = Me.FakSted
Kommentar = Me.Kommentar
C = Forms!EndreAlle!Sendt
'A = DSum("[Query2].[AntalAvMasternr]", "Query2")
'B = DLookup("[Mottaker]", "Mottaker", "MottakerID = " & Forms!EndreAlle!Sendt)
'MsgBox A
'MsgBox B
strSql = "INSERT INTO Ordrer (Antall, Dato, Mottaker, LevNavn, LevAtt, LevAdr, LevSted, FakNavn, FakAtt, FakAdr, FakSted, Kommentar) VALUES (" & A & ", " & SQLDate(Date) & ", '" & B & "', '" & Me.LevNavn & "', '" & Me.LevAtt & "', '" & Me.LevAdr & "', '" & Me.LevSted & "', '" & Me.FakNavn & "', '" & Me.FakAtt & "', '" & Me.FakAdr & "', '" & Me.FakSted & "', '" & Me.Kommentar & "')"
'MsgBox strSql
MsgBox C
'CurrentDb.Execute strSql
 

End Sub

As you see, i have a pretty brutal SQL here, but thats not my problem.

The problem is the A and B.

A and B turns out to be empty, and it say it cant find the EndreAlle form, but the EndreAlle-form is there. Isnt Forms!FromForm!Controll the standard way to retrieve values from kontrolls in other forms?
 
As long as the EndreAlle form is open and has a control named Sendt
Try this first:
A = DSum("AntalAvMasternr", "Query2")
And this one you are you saying the column name and the table name are the same?
B = DLookup("[Mottaker]", "Mottaker", "MottakerID = " & Forms!EndreAlle!Sendt)
 

Users who are viewing this thread

Back
Top Bottom