Hi all,
I have a Problem with combobox-property "NotInList" and an unbound Form.
The situation:
On my main form i have three comboboxes for data-exchange (here: Names of
distributor, reseller and final customers[1], the whole database is made
for storing information about quotatations[2] - no, not for quoting itself)
ut the boxes actually may not contain all our distributors and reseller's
names (and final customers are not stored anywhere up to now) and
therefore, I want to give the users (me and a colleague ;) the possibility
to enter a customers name if during input it ist detected, that it isn't
stored.
For this purpose i use the "NotInList" property and i use it up to now with
a bound form - works good.
But now i wish to change to unbound form because i wish to pretend some
input-errors like leading/following spaces (for instance thew customer's
name is 'Multimedia Inc' but the user by mistake types
in '<space>Mutimed ia Inc'n - the next time another user types
in 'Multimedia Inc' it won't be found yet because of the leading space).
My problem:
I cannot get my code working.
This is my code for the combobox (here: final customer):
-------------
Private Sub cboFinalCustome r_NotInList(New Data As String, Response As
Integer)
On Error GoTo fehler
Dim erg As Integer
Response = acDataErrAdded
'MessageBox einblenden
erg = MsgBox("Der Eintrag '" & NewData & "' ist nicht in der Liste."
_
& "Möchten Sie den Eintrag erfassen?", vbYesNo + vbExclamation)
'Wenn OK gedrückt, Erfassungsdialo g zeigen
If erg = vbYes Then
DoCmd.SetWarnin gs False
Response = acDataErrContin ue
DoCmd.OpenForm "frmFinalCustom erErfassung", DataMode:=acFor mAdd,
windowmode:=acD ialog, OpenArgs:=NewDa ta
'Warnungen wieder einschalten
DoCmd.SetWarnin gs True
Else
Response = acDataErrContin ue
Me!cboFinalCust omer.Undo
End If
ende:
Exit Sub
fehler:
Me!cboFinalCust omer.Value = Me!cboFinalCust omer.ItemData(0 )
Resume ende
End Sub
---------------------
And the following is my code for the unbound input form
----
Private Sub cmdCancel_Click ()
Dim erg As Long
'Message-Box erzeugen und Anzeigen
erg = MsgBox("Eingabe Abbrechen?", Buttons:=vbYesN o + vbExclamation,
Title:="Final Customer Eingabe")
'wenn Abbruch bestätigt
If erg = vbYes Then
'dann Formular schliessen
DoCmd.Close
Else
'Zurück zum letzten Steuerelement
Screen.Previous Control.SetFocu s
End If
End Sub
Private Sub cmdSave_Click()
'Eigene speichern-Routine wg. Nachbehandlung der Eingaben
Dim db As DAO.Database
Dim rsFinalCustomer As DAO.Recordset
On Error GoTo err_cmdStore
Set db = CurrentDb()
'Tabelle Final Customer öffnen
Set rsFinalCustomer = db.OpenRecordse t("tblFinalCust omer")
'Speichern mit Nachbehandlung
With rsFinalCustomer
'neuen Datensatz anfügen
.AddNew
'Textfeldinhalt umkopieren
!strFinalName = Trim(txtFinalNa me.Value)
'Datensatz schreiben
.Update
'Recordset schliessen
.Close
End With
end_cmdSave
'Datenbankobjek te zerstören
db.Close
Set rsFinalCustomer = Nothing
Set db = Nothing
Exit Sub
err_cmdSave
MsgBox Err.Description
Resume end_cmdSpeicher n
End Sub
Private Sub Form_Close()
Forms!frmMaster Test!cboFinalCu stomer.Requery *
End Sub
Private Sub Form_Load()
Me!txtFinalName .SetFocus
Me!txtFinalName .Value = Me.OpenArgs
End Sub
--------
* here i get an Error "Item must be saved before requery"
I couldn't figure out where's my mistake/error in reasoning whole day.
Can anybody help me coming on the right way?
Volker
[1]Only names are stored not whole adresses. Just names and SAP number
[2]Our systems are limited in several functions so i try to get over
those limitations by using access - quotations themselves are
made with a web-tool based on SAP netweaver
--
Im übrigen bin ich der meinung, dass TCPA/TCG verhindert werden muss
I have a Problem with combobox-property "NotInList" and an unbound Form.
The situation:
On my main form i have three comboboxes for data-exchange (here: Names of
distributor, reseller and final customers[1], the whole database is made
for storing information about quotatations[2] - no, not for quoting itself)
ut the boxes actually may not contain all our distributors and reseller's
names (and final customers are not stored anywhere up to now) and
therefore, I want to give the users (me and a colleague ;) the possibility
to enter a customers name if during input it ist detected, that it isn't
stored.
For this purpose i use the "NotInList" property and i use it up to now with
a bound form - works good.
But now i wish to change to unbound form because i wish to pretend some
input-errors like leading/following spaces (for instance thew customer's
name is 'Multimedia Inc' but the user by mistake types
in '<space>Mutimed ia Inc'n - the next time another user types
in 'Multimedia Inc' it won't be found yet because of the leading space).
My problem:
I cannot get my code working.
This is my code for the combobox (here: final customer):
-------------
Private Sub cboFinalCustome r_NotInList(New Data As String, Response As
Integer)
On Error GoTo fehler
Dim erg As Integer
Response = acDataErrAdded
'MessageBox einblenden
erg = MsgBox("Der Eintrag '" & NewData & "' ist nicht in der Liste."
_
& "Möchten Sie den Eintrag erfassen?", vbYesNo + vbExclamation)
'Wenn OK gedrückt, Erfassungsdialo g zeigen
If erg = vbYes Then
DoCmd.SetWarnin gs False
Response = acDataErrContin ue
DoCmd.OpenForm "frmFinalCustom erErfassung", DataMode:=acFor mAdd,
windowmode:=acD ialog, OpenArgs:=NewDa ta
'Warnungen wieder einschalten
DoCmd.SetWarnin gs True
Else
Response = acDataErrContin ue
Me!cboFinalCust omer.Undo
End If
ende:
Exit Sub
fehler:
Me!cboFinalCust omer.Value = Me!cboFinalCust omer.ItemData(0 )
Resume ende
End Sub
---------------------
And the following is my code for the unbound input form
----
Private Sub cmdCancel_Click ()
Dim erg As Long
'Message-Box erzeugen und Anzeigen
erg = MsgBox("Eingabe Abbrechen?", Buttons:=vbYesN o + vbExclamation,
Title:="Final Customer Eingabe")
'wenn Abbruch bestätigt
If erg = vbYes Then
'dann Formular schliessen
DoCmd.Close
Else
'Zurück zum letzten Steuerelement
Screen.Previous Control.SetFocu s
End If
End Sub
Private Sub cmdSave_Click()
'Eigene speichern-Routine wg. Nachbehandlung der Eingaben
Dim db As DAO.Database
Dim rsFinalCustomer As DAO.Recordset
On Error GoTo err_cmdStore
Set db = CurrentDb()
'Tabelle Final Customer öffnen
Set rsFinalCustomer = db.OpenRecordse t("tblFinalCust omer")
'Speichern mit Nachbehandlung
With rsFinalCustomer
'neuen Datensatz anfügen
.AddNew
'Textfeldinhalt umkopieren
!strFinalName = Trim(txtFinalNa me.Value)
'Datensatz schreiben
.Update
'Recordset schliessen
.Close
End With
end_cmdSave
'Datenbankobjek te zerstören
db.Close
Set rsFinalCustomer = Nothing
Set db = Nothing
Exit Sub
err_cmdSave
MsgBox Err.Description
Resume end_cmdSpeicher n
End Sub
Private Sub Form_Close()
Forms!frmMaster Test!cboFinalCu stomer.Requery *
End Sub
Private Sub Form_Load()
Me!txtFinalName .SetFocus
Me!txtFinalName .Value = Me.OpenArgs
End Sub
--------
* here i get an Error "Item must be saved before requery"
I couldn't figure out where's my mistake/error in reasoning whole day.
Can anybody help me coming on the right way?
Volker
[1]Only names are stored not whole adresses. Just names and SAP number
[2]Our systems are limited in several functions so i try to get over
those limitations by using access - quotations themselves are
made with a web-tool based on SAP netweaver
--
Im übrigen bin ich der meinung, dass TCPA/TCG verhindert werden muss
Comment