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?