473,378 Members | 1,549 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

'Problem with NotInList and unbound Form

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
Aug 1 '08 #1
6 2650
Perhaps there's a compelling reason, but I don't see why you do not validate
and edit the information in the Before Update and After Update properties of
the Controls and of the Form itself, and use a Bound Form. There are rare
times when it is needful to use an unbound form for handling data, but those
times are _rare indeed_. In any case, "unbound" or not, I would presume
that you are using a Table or Query as the Row Source on the Combo Box, so a
"standard solution" for that should work just fine.

That is, pop up a form to enter the missing Row Source information, save it,
and return. There are quite a number of examples... many can be found by
using http://groups.google.com to search the archives here; others can be
found in resources linked from my SharePoint page at
http://sp.ntpcug.org/accesssig/default.aspx (see the Resources list on that
same page).

Larry Linson
Microsof Office Access MVP
"Volker Neurath" <ne*******@gmx.dewrote in message
news:tm************@ID-29596.user.individual.de...
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

Aug 1 '08 #2
Hi, Larry

Larry Linson wrote:
There are quite a number of examples... many
can be found by using http://groups.google.com to search the archives
here; others can be found in resources linked from my SharePoint page
at http://sp.ntpcug.org/accesssig/default.aspx (see the Resources
list on that same page).
Right, and some links were already given in the german newsgroup.
There is a sample in Rogers Access Library :

http://www.rogersaccesslibrary.com/d...=NotInList.mdb

This sample is very close to the requested needs - even though there is no
unbound form used.

But some prefer to follow their own ideas...

Regards
Jens
Aug 1 '08 #3
Jens Schilling wrote:
But some prefer to follow their own ideas...
No - Im asking to either get help or other/new ideas.

The idea with using an unbound form came up because i didn't have any idea
how to catch and handle input-errors when using a bound form.
Now .. "before update" and "after update" of both, form and control, are the
keywords I didn't hit on all the time since yesterday.

Sorry for asking such simple questions but sometimes there are days you do
not see the wood for trees... and then you just need a helpful person who
puts you right back an your way by just giving the right keywords.

Therefore: thank you, Larry.

Volker
--
Im übrigen bin ich der meinung, dass TCPA/TCG verhindert werden muss
Aug 2 '08 #4
Larry Linson wrote:
Perhaps there's a compelling reason, but I don't see why you do not
validate and edit the information in the Before Update and After Update
properties of the Controls and of the Form itself, and use a Bound Form.
Outch! These arte the keywords i dind't hit on since yesterday.

Thank you for just putting me back on the right way.
and return. There are quite a number of examples... many can be found by
using http://groups.google.com to search the archives here;
but only by typing the right keywords - an that's what i was missing.

I fully ran out of ideas, just had a hole in my head.
found in resources linked from my SharePoint page at
http://sp.ntpcug.org/accesssig/default.aspx (see the Resources list on
that same page).
Thank you for that link. I'll check it out on monday, in the bureau.

I think i need these two days without having to do too much with Access ;)

Volker
--
Im übrigen bin ich der meinung, dass TCPA/TCG verhindert werden muss
Aug 2 '08 #5
Hi,

Volker Neurath wrote:
Jens Schilling wrote:
>But some prefer to follow their own ideas...
No - Im asking to either get help or other/new ideas.
The idea with using an unbound form came up because i didn't have any
idea how to catch and handle input-errors when using a bound form.
I'm a bit disappointed regarding your own efforts.
What more do you need than the examples labeled as Option 5 or Option 6 in
the sample of Rogers Access Library ?
There is a form opened that gives you the ability to edit the data you have
entered to the combo box.

So - what's your problem ???

Do you need more samples regarding the "NotInList-Event"?

OK, here we go:

http://home.comcast.net/~cccsolutions/accesstips.html
Not In List Combobox (Forms)

http://www.datadynamicsnw.com/seattl.../downloads.htm
Not In List - Detailed Instructions by Tom Wickerath

http://www.databasedev.co.uk/downloads.html
Using the Combo Box's NotInList event with multiple fields

http://www.geocities.com/pmpg98_pt/NotInList.html
NotInList

http://www.access-programmers.co.uk/...ad.php?t=97434
MultiNotInList.zip by ChrisO - post no. 14

And at last a german sample

http://www.access-home.de/accbsp2.htm
Ereignis 'NotInList' eines Kombinationsfeldes

Regards
Jens


Aug 2 '08 #6
Jens Schilling wrote:
I'm a bit disappointed regarding your own efforts.
Why? I can assure you: there's no need for.
What more do you need than the examples labeled as Option 5 or Option 6 in
the sample of Rogers Access Library ?
Sorry, yesterday evening i didn't explore any of those links yet. As i said
in my post above: I felt a had a hole in my head an being empty and at the
same time too full to get anything in.

Having slept a night over it I'm now of the opinion, i shouldn't have asked
here too - not before having explored all the links given in m.p.d.a.

I today had some short looks on some of them and what i've seen there looks
very auspicious to me - I'm shure now I will solve my "problem".

I put the blame on the fact that i felt a kind of exhaustion or so.
Cannot really describe my situtation yesterday.
Today it seems to me that yesterday I didn't even really know what I was
looking for :(
You know how this feels (at least when you realize it)?

As I said in the german group yesterday: it was my off day
(including: brain.enabled=false) :->
Do you need more samples regarding the "NotInList-Event"?

OK, here we go:

http://home.comcast.net/~cccsolutions/accesstips.html
Not In List Combobox (Forms)

http://www.datadynamicsnw.com/seattl.../downloads.htm
Not In List - Detailed Instructions by Tom Wickerath

http://www.databasedev.co.uk/downloads.html
Using the Combo Box's NotInList event with multiple fields

http://www.geocities.com/pmpg98_pt/NotInList.html
NotInList

http://www.access-programmers.co.uk/...ad.php?t=97434
MultiNotInList.zip by ChrisO - post no. 14
Thank you once again.
And at last a german sample

http://www.access-home.de/accbsp2.htm
Ereignis 'NotInList' eines Kombinationsfeldes
I've downloaded their two examples at the bureau yesterday - shortly before
i left it. I'll study them on monday, like all the other links.

Today and tomorry i use for relaxation - it's badly necessary

Volker
--
Im übrigen bin ich der meinung, dass TCPA/TCG verhindert werden muss
Aug 2 '08 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Pieter Linden | last post by:
Just got done reading some of ADH2000 about comboboxes and the NotInList event... Doesn't look like it's possible to tweak the behavior of this so that I can have a non-text bound column, can I?...
1
by: Alex.Wisnoski | last post by:
I have a data entry form with a combo box to look up an entrant's name. If the name is already in the table then it pulls up the record and that part of the form works fine. If the name isn't in...
2
by: whilstiwait | last post by:
I have a form containing a number of unbound combo boxes in three columns. Each column has boxes named "aaaa0", "aaaa1", etc. Using syntax like: With Forms(Me.Form.Name).Controls("txtTechnology"...
4
by: CAD Fiend | last post by:
Hello, I have a combo box (cmbFirstName) on a form that is hitting a query (qryFirstName) and then putting that selected (or typed by user) value to the table field (name FirstName) on the table...
11
by: my-wings | last post by:
I think I've painted myself into a corner, and I'm hoping someone can help me out. I have a table of books (tblBooks), which includes a field (strPubName) for Publisher Name and another field...
7
by: Bryan | last post by:
I am trying to allow the user to add an item to a list if it is not found in a combobox. When the NotInList event is triggered I run a function "AddItem" that has a custom dialog box to add an...
1
by: JHite | last post by:
I am using Access 2003. My Form has 4 fields: MailingListID, auto generated – primary key LastName FirstName NickName I used the Combo box wizard to set up look-up box on the form. I answered...
2
imrosie
by: imrosie | last post by:
Hello, I have a search form that uses a row query to locate a customer by customerID and first & last names, so it's an unbound control. I also have two events associated with this control,...
4
by: EManning | last post by:
I have a combobox whose rowsource is a union query. This query displays a person's name in "lastname, firstname" format and in "firstname lastname" format. The query results look like this: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.