Perhaps there's a compelling reason, but I don't see why you do not validate
the Controls and of the Form itself, and use a Bound Form. There are rare
times are _rare indeed_. In any case, "unbound" or not, I would presume
"standard solution" for that should work just fine.
and return. There are quite a number of examples... many can be found by
same page).
news:tm4cm5-d77.ln1@ID-29596.user.individual.de...
Quote:
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>Mutimedia 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 cboFinalCustomer_NotInList(NewData 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, Erfassungsdialog zeigen
If erg = vbYes Then
DoCmd.SetWarnings False
Response = acDataErrContinue
DoCmd.OpenForm "frmFinalCustomerErfassung", DataMode:=acFormAdd,
windowmode:=acDialog, OpenArgs:=NewData
>
'Warnungen wieder einschalten
DoCmd.SetWarnings True
>
Else
Response = acDataErrContinue
Me!cboFinalCustomer.Undo
End If
>
ende:
Exit Sub
>
fehler:
Me!cboFinalCustomer.Value = Me!cboFinalCustomer.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:=vbYesNo + 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.PreviousControl.SetFocus
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.OpenRecordset("tblFinalCustomer")
>
'Speichern mit Nachbehandlung
With rsFinalCustomer
'neuen Datensatz anfügen
.AddNew
>
'Textfeldinhalt umkopieren
!strFinalName = Trim(txtFinalName.Value)
>
'Datensatz schreiben
.Update
>
'Recordset schliessen
.Close
End With
>
end_cmdSave
'Datenbankobjekte zerstören
db.Close
Set rsFinalCustomer = Nothing
Set db = Nothing
>
Exit Sub
>
err_cmdSave
MsgBox Err.Description
Resume end_cmdSpeichern
End Sub
Private Sub Form_Close()
>
Forms!frmMasterTest!cboFinalCustomer.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