|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
hi,
i got a problem here. i have 2 combo box, cbo1 contains a, b ,c cbo2 contains 1, 2, 3 when i choose a, i want the cbo2 display 1 automatically, what should i do? help me plz ..... thanks... |
|
#2
|
|||
|
|||
|
I have this strange feeling there is a lot more to this question than what you posted, so I will give you the direct answer and then you can post back with your follow-up questions:
In the AfterUpDate event If cbo1 = "a" Then cbo2 = 1 End If lwells |
|
#3
|
|||
|
|||
|
Iwells,
thank you for your reply.sorry, let me giv an example here i got a table with empID and product empID n product is the one which is assigned into those combo boxes that i mentioned. if i choose the empID in lets say cbo1, cbo2 (product) i wan it to display the data automatically. i do not want to assign the value 1 to 1 ( like a = 1), what i want is an overall code, which can apply to many empIDs n products ... hope u understand what i mean .. thanks Jessica |
|
#4
|
|||
|
|||
|
Hi Jessica,
What it sounds like you are wanting to do, is when you display each empID in cbo1, you want to requery or change the list of available Products in cbo2 that will relate or match to empID. In the properties for cbo2, create a query for the recordsource and add the empID from cbo1 to the criteria for the cbo2 empID. Something like [Forms]![NameOfForm]![cbo1] The empID would have to be the bound column in cbo1 in this example. Then in the AfterUpdate event for cbo1 just add this code to requery the list in cbo2: Me.Refresh Now when you select an empID in cbo1, cbo2 will change the list of available products that match to the empID. Was this what you were looking for? lwells |
|
#5
|
|||
|
|||
|
hi Iswell,
sorry but i cant get what i suppose to get.. the cbo2 jz came out blank.. i have another question: how to match a value (enter by user) with data from a table? for example, user enter product code, then the machine will match the product code for product name = ABC(the data already in the table) , then go to a form (what i mean is an overall command .. not for a product name only) Thanks Jessica |
|
#6
|
|||
|
|||
|
Hi Jessica,
How did you set up your rowsource for the cbo2? Try posting the sql so I can see how you have it set up. For you second question, just include the criteria in your open form command. Assuming that the product code and the product name are in the same record and you are opening a form from a command button: Dim stDocName As String Dim strTemp As String stDocName = "Your Form Name Here" strTemp = "What the User typed In" DoCmd.OpenForm stDocName, , , "[Product Code] = '" & strTemp & "'" Use the wizard to help build the code and then go in and modify slightly for your use. lwells |
|
#7
|
|||
|
|||
|
hi Iwells,
here is the row source sql: SELECT tblUsers.ProName FROM tblUsers WHERE (((tblUsers.ProName)=[forms]![pro]![cboUser])); for the coding that you have wrote for me, it works. i wonder if there is any way to do an action of open for with 2 conditions? eg : i enter product code and employee ID, then if it is in category A, it will go to form 1, if it is in category B it will go to form 2 .. and so on ... Thanks. Regards, Jessica |
|
#8
|
|||
|
|||
|
Hi Jessica,
The row source looks okay, did you refresh the form after you updated the cbo1? Your second question, using two criterias will work similar. Because you are going to use an If condition depending on the category, then I would probably look at using a DLookup to determine which category it is and then open the appropriate form. Dim stCat As String Dim stDocName As String Dim stID As String, strTemp As String strCat = DLookUp("[Category]","NameOfTable","[employeeID] = " & stID And "[ProductCode] = '" & strTemp & "'") If strCat = "A" Then stDocName = Form1 DoCmd.OpenForm stDocName ElseIf strCat = "B" Then stDocName = Form2 DoCmd.OpenForm stDocName End If There are varieties of ways of doing this including a Select Case which would be faster if you had lots of different forms to open. With just two selections it won't matter. lwells |
|
#9
|
|||
|
|||
|
hi Iwells,
i did put "me.refresh" in AfterUpdate for cbo1 then i put the sql statement in the raw source of cbo2, was my step done wrongly? the DlookUp returns empty value for strCat, what problem could it be? it returns run time error '13' . Type Missmatch. i change the stID and strTemp in the DlookUp to ".value" , which will take the value directly from what user will key in, is it the where the problem is? Do i need to add a 'Category' column in my table as well? Thanks. Regards, Jessica |
|
#10
|
|||
|
|||
|
Hi Jessica,
Send me a copy of your database and let me see what you are doing and the table structure. When you mentioned category, I was assuming that was in your table. I know that it is sometimes difficult to explain what you are wanting to do and still have it make sense, so maybe if I see what you are doing it will be alot clearer to me. By the way, where is category if not in a table someplace...how are you going to distinguish which records go with form1 and which records go with form2? Send the database to lwells1433@aol.com and let me review it. You can leave out anything that is confidential, I can make bogus records based on data types for testing. lwells |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > matching problem |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|