LimitToList Event

A

Alain

Hi,

I and using the LimitToList Event to be able to add new data if it is not
existing in my table
my problem is the event does not seem to fire at all, the code I wrote is
fine (I think ) and the Limit To List is set to No.
What can cause this problem, I do not even see my msg from my code

On Error GoTo cboCurrency_NotInList_Err
Dim strmsg As String, strSQL As String

strmsg = "'" & NewData & "' is not in the list."
strmsg = strmsg & vbCrLf & vbCrLf & "Click Yes to add to list or No to
not add to list."

If MsgBox(strmsg, vbQuestion + vbYesNo, "Add new currency?") = vbNo Then
Response = acDataErrContinue
Else
strSQL = "INSERT INTO tblCurrency([Currency] VALUES ('" & NewData &
"');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "New currency added to the list", vbInformation, "Iata"
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If

End If
cboCurrency_NotInList_Exit:
Exit Sub
cboCurrency_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume cboCurrency_NotInList_Exit

TIA

Alain
 
S

Steve Conway

Alain said:
Hi,

I and using the LimitToList Event to be able to add new data if it is not
existing in my table
my problem is the event does not seem to fire at all, the code I wrote is
fine (I think ) and the Limit To List is set to No.
What can cause this problem, I do not even see my msg from my code

On Error GoTo cboCurrency_NotInList_Err
Dim strmsg As String, strSQL As String

strmsg = "'" & NewData & "' is not in the list."
strmsg = strmsg & vbCrLf & vbCrLf & "Click Yes to add to list or No to
not add to list."

If MsgBox(strmsg, vbQuestion + vbYesNo, "Add new currency?") = vbNo
Then
Response = acDataErrContinue
Else
strSQL = "INSERT INTO tblCurrency([Currency] VALUES ('" & NewData &
"');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "New currency added to the list", vbInformation, "Iata"
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If

End If
cboCurrency_NotInList_Exit:
Exit Sub
cboCurrency_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume cboCurrency_NotInList_Exit

TIA

Alain

Hi Alain,

The Limit to List property must be set to *yes* in order for the event to
fire when an item *not in the list* is entered.

HTH
Steve C
 
A

Alain

Thanks,

but I do not quite understand the reason to set to yes, my understanding is
if Limit To List is no then the new value is not in the list so you can add
it to the list with the event, if it is set to yes the you must stick to the
values on the list and cannot anything new, so I am confuse as why it is
reverse

Alain


Chaim said:
LimitToList must be set to Yes.
--
Chaim


Alain said:
Hi,

I and using the LimitToList Event to be able to add new data if it is not
existing in my table
my problem is the event does not seem to fire at all, the code I wrote is
fine (I think ) and the Limit To List is set to No.
What can cause this problem, I do not even see my msg from my code

On Error GoTo cboCurrency_NotInList_Err
Dim strmsg As String, strSQL As String

strmsg = "'" & NewData & "' is not in the list."
strmsg = strmsg & vbCrLf & vbCrLf & "Click Yes to add to list or No
to
not add to list."

If MsgBox(strmsg, vbQuestion + vbYesNo, "Add new currency?") = vbNo
Then
Response = acDataErrContinue
Else
strSQL = "INSERT INTO tblCurrency([Currency] VALUES ('" & NewData
&
"');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "New currency added to the list", vbInformation, "Iata"
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If

End If
cboCurrency_NotInList_Exit:
Exit Sub
cboCurrency_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume cboCurrency_NotInList_Exit

TIA

Alain
 
S

Steve Conway

Hi Alain,

The yes/no applies to *entry* if you set it to no you are saying 'let the
user enter anything' whereas when set to yes you are saying 'only items in
this list can be entered, if something not in this list is entered call the
Not in List event'

HTH
Steve C

Alain said:
Thanks,

but I do not quite understand the reason to set to yes, my understanding
is if Limit To List is no then the new value is not in the list so you can
add it to the list with the event, if it is set to yes the you must stick
to the values on the list and cannot anything new, so I am confuse as why
it is reverse

Alain


Chaim said:
LimitToList must be set to Yes.
--
Chaim


Alain said:
Hi,

I and using the LimitToList Event to be able to add new data if it is
not
existing in my table
my problem is the event does not seem to fire at all, the code I wrote
is
fine (I think ) and the Limit To List is set to No.
What can cause this problem, I do not even see my msg from my code

On Error GoTo cboCurrency_NotInList_Err
Dim strmsg As String, strSQL As String

strmsg = "'" & NewData & "' is not in the list."
strmsg = strmsg & vbCrLf & vbCrLf & "Click Yes to add to list or No
to
not add to list."

If MsgBox(strmsg, vbQuestion + vbYesNo, "Add new currency?") = vbNo
Then
Response = acDataErrContinue
Else
strSQL = "INSERT INTO tblCurrency([Currency] VALUES ('" &
NewData &
"');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "New currency added to the list", vbInformation, "Iata"
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If

End If
cboCurrency_NotInList_Exit:
Exit Sub
cboCurrency_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume cboCurrency_NotInList_Exit

TIA

Alain
 
A

Alain

Thank you very much
much clearer now

Alain

Steve Conway said:
Hi Alain,

The yes/no applies to *entry* if you set it to no you are saying 'let the
user enter anything' whereas when set to yes you are saying 'only items in
this list can be entered, if something not in this list is entered call
the Not in List event'

HTH
Steve C

Alain said:
Thanks,

but I do not quite understand the reason to set to yes, my understanding
is if Limit To List is no then the new value is not in the list so you
can add it to the list with the event, if it is set to yes the you must
stick to the values on the list and cannot anything new, so I am confuse
as why it is reverse

Alain


Chaim said:
LimitToList must be set to Yes.
--
Chaim


:

Hi,

I and using the LimitToList Event to be able to add new data if it is
not
existing in my table
my problem is the event does not seem to fire at all, the code I wrote
is
fine (I think ) and the Limit To List is set to No.
What can cause this problem, I do not even see my msg from my code

On Error GoTo cboCurrency_NotInList_Err
Dim strmsg As String, strSQL As String

strmsg = "'" & NewData & "' is not in the list."
strmsg = strmsg & vbCrLf & vbCrLf & "Click Yes to add to list or No
to
not add to list."

If MsgBox(strmsg, vbQuestion + vbYesNo, "Add new currency?") = vbNo
Then
Response = acDataErrContinue
Else
strSQL = "INSERT INTO tblCurrency([Currency] VALUES ('" &
NewData &
"');"
DoCmd.SetWarnings False
DoCmd.RunSQL strSQL
DoCmd.SetWarnings True
MsgBox "New currency added to the list", vbInformation, "Iata"
If Err Then
MsgBox "An error occurred. Please try again."
Response = acDataErrContinue
Else
Response = acDataErrAdded
End If

End If
cboCurrency_NotInList_Exit:
Exit Sub
cboCurrency_NotInList_Err:
MsgBox Err.Description, vbCritical, "Error"
Resume cboCurrency_NotInList_Exit

TIA

Alain
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

NotInList not firing ? 1
Not in list not working 1
Help With Code Please 5
Not in list requery issue 4
Not In List help needed 1
Not In List 2 values 5
NotInList Problem 3
Combo Box Adding to List--Error 91 2

Top