Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combo boxes used in a selective way 2

Status
Not open for further replies.

joe8915

Technical User
Jun 27, 2005
13
0
0
US
I have several combo boxes (with the same data in each). I do this for several reasons.

Here is the bottom line, I have all these combo boxes on one form. I do not any duplicates from the combo boxes. Is this possible.
 
Do you have any idea how you want to implement this? When the form opens, I assume they might all be the same. Are they bound to fields in a Record Source?

Is there some context, you could share about why you are attempting to do this?

Duane
Hook'D on Access
MS Access MVP
 
How are ya joe8915 . . .
joe8915 said:
[blue]I have all these combo boxes on one form. I do not any duplicates from the combo boxes. Is this possible.[/blue]
Provide a detailed explanation of the quote. Bear in mind we are not mind readers ... nor can we see what your looking at!

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I apologized for not giving you more information. I reconstructed the form to where I have only one subform and one combo box within that subform. I hope with the following information it will make more sense.
1. Main Form called FrmBatch2b
Record Source TblTimeCard2
2. Subform Called TblName subform
Link Master field is ID
Link Child field is Name_ID
In the Subform I have two fields
1. Called Name_ID
2. Called FullName (I have changed Fullname to a combo box)
Control Source is Fullname
Row Source is SELECT TblEmpName.FullName, TblEmpName.Name_ID FROM TblEmpName ORDER BY TblEmpName.FullName;
Row Source Type is Table/Query

I have pasted this code:
Private Sub LastName_BeforeUpdate(Cancel As Integer)
If DCount("*", "[TblEmpName]", "[lastname_ID] = '" & Me.[Lastname_ID] & "'") <> 0 Then
Cancel = True
MsgBox "cannot save duplicate", vbExclamation, "Duplicate"
End If
End Sub
I receive a error Object or class does not support the set of events

 

For starters, I'd replace the * with a field name in your table.

Also, it seems you have a FullName field in your table along with First and Last name fields. This is virtually the same as storing calculated data. You should find full names with a query.

Then, you might use something like this:
Code:
If DCount("FullName", "qryFullName", "Lastname_ID = '" & Me.Lastname_ID & "'") > 0 Then
If the Lastname_ID field is numeric, drop the single quotes.


Randy
 
Randy, I was happy to see the Msg Box pop up. But I need to at least have it to be selected one time, but not twice.
 
If DCount("FullName", "qryFullName", "name_ID = '" & Me.name_id & "'") > 0 Then
Cancel = True
MsgBox "cannot save duplicate", vbExclamation, "Duplicate"
End If
 
joe8915 . . .

Is [blue]Name_ID[/blue] the actual employee [blue]lastname[/blue] or what?

And where does [blue]Name_ID[/blue] reside?

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
joe8915 . . .

My last post should've read:

Is Lastname_ID the actual employee lastname or what?

And where does Lastname_ID reside?


See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
AceMan1, thanks for being so patience with me, I am so new with code I have a hard time understanding, as you can see. When I saw that message pop up I was so never happy, until I realize that I need to at least have them be able to select their name once.
If you like I would be more than happy to send a copy of the db to you and see how I have it sit up.

I screw up and the lastname_ID was changed to Name_ID, due to a power failure here and I lost my subform and had to start all over again. So where you had lastname_ID is now called NAME_ID. My sincere apologies.

In the table TblEmpName:
I have a field called name_ID. The field is associated with the field called “Fullname”

In the TblEmpName Subform:
The Record Source is:
SELECT [TblEmpName].[FullName], [TblEmpName].[name_id] FROM TblEmpName;

 
I would like to give a big shout out to:
dhookm
The AceMan1
Randy700

For trying to make this work for me. I know I was not at the best of explaing it. But we got it very close to accomplishing the task, once again guys thanks.

Joe
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top