G
Guest
Hi, i get a error message while trying to add a new record through the not in list value, the error is "you cant fix a value to this object", and then a message about wrong data value i exppression. im using the following code in the text.box:
Private Sub Organisasjonsnummer_NotInList(NewData As String, Response As Integer)
Dim strsql As String, x As Integer
Dim FindCriteria As String
x = MsgBox("Dette selskapet er ikke registrert tidligere, vil du registrere selskapet? Det er nødvendig for å kunne fortsette registreringen!", vbYesNo)
If x = vbYes Then
strsql = "Insert Into Selskap ([organisasjonsnummer]) values ('" & NewData & "')"
'MsgBox strsql
CurrentDb.Execute strsql, dbFailOnError
FindCriteria = Me!Organisasjonsnummer.Text
DoCmd.OpenForm "Selskap", , , , , , FindCriteria
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
and as open form in the form i wish to add the value (so the form opens with the value adden in the text box:
Option Compare Database
Option Explicit
Dim Orgnr As String
Private Sub Form_Load()
Me.RecordsetClone.FindFirst "[organisasjonsnummer] = '" & Organisasjonsnummer & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
Organisasjonsnummer = Nz(Me.OpenArgs)
Exit_Form_Open:
Exit Sub
Err_Form_Open:
MsgBox Error$
Resume Exit_Form_Open
End Sub
Is there any good sugestions to how to solve this problem. The field organisasjonsnummer is a text field in all tables involved.
Thanks..
Private Sub Organisasjonsnummer_NotInList(NewData As String, Response As Integer)
Dim strsql As String, x As Integer
Dim FindCriteria As String
x = MsgBox("Dette selskapet er ikke registrert tidligere, vil du registrere selskapet? Det er nødvendig for å kunne fortsette registreringen!", vbYesNo)
If x = vbYes Then
strsql = "Insert Into Selskap ([organisasjonsnummer]) values ('" & NewData & "')"
'MsgBox strsql
CurrentDb.Execute strsql, dbFailOnError
FindCriteria = Me!Organisasjonsnummer.Text
DoCmd.OpenForm "Selskap", , , , , , FindCriteria
Response = acDataErrAdded
Else
Response = acDataErrContinue
End If
End Sub
and as open form in the form i wish to add the value (so the form opens with the value adden in the text box:
Option Compare Database
Option Explicit
Dim Orgnr As String
Private Sub Form_Load()
Me.RecordsetClone.FindFirst "[organisasjonsnummer] = '" & Organisasjonsnummer & "'"
Me.Bookmark = Me.RecordsetClone.Bookmark
End Sub
Private Sub Form_Open(Cancel As Integer)
On Error GoTo Err_Form_Open
Organisasjonsnummer = Nz(Me.OpenArgs)
Exit_Form_Open:
Exit Sub
Err_Form_Open:
MsgBox Error$
Resume Exit_Form_Open
End Sub
Is there any good sugestions to how to solve this problem. The field organisasjonsnummer is a text field in all tables involved.
Thanks..