Combo box

A

a

Thank you for your help and reply

Klatuu said:
Use the Before Update event of the combo. Use a DLookup to determine if
the
number exists:

Private Sub MyCombo_BeforeUpdate(Cancel As Integer)

If Not IsNull(Dlookup("[NumberField]", "TableName", "[NumberField] = "
&
Me.MyCombo)) Then
MsgBox "The Number " & Me.MyCombo & " Already Exists"
Cancel = True
End If

End Sub
--
Dave Hargis, Microsoft Access MVP


a said:
If you have combo box with this List:

1

2

3

4

5

etc



What I want

If you type any number in the list msgbox tell you that the number exist;

(There is Duplicate in Entry)



Notes:

I can't use limit to list:

Because:

1-The combo box maybe not contain any data.

2-I will add new data to combo box.



What I want to tell you:

I want to prevent duplicate in entry

So the code you will write will check the combo box if the number not
exists
continue else display message box there is duplicate in entry

I hope you understand me
 
A

a

If you have combo box with this List:

1

2

3

4

5

etc



What I want

If you type any number in the list msgbox tell you that the number exist;

(There is Duplicate in Entry)



Notes:

I can't use limit to list:

Because:

1-The combo box maybe not contain any data.

2-I will add new data to combo box.



What I want to tell you:

I want to prevent duplicate in entry

So the code you will write will check the combo box if the number not exists
continue else display message box there is duplicate in entry

I hope you understand me
 
K

Klatuu

Use the Before Update event of the combo. Use a DLookup to determine if the
number exists:

Private Sub MyCombo_BeforeUpdate(Cancel As Integer)

If Not IsNull(Dlookup("[NumberField]", "TableName", "[NumberField] = " &
Me.MyCombo)) Then
MsgBox "The Number " & Me.MyCombo & " Already Exists"
Cancel = True
End If

End Sub
 

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

Top