First and foremost, thank you for your time in reviewing my post and offering your advice. I have a database with the following schema:
tblPR:
PRID
Title
Amount
Status
tblProgram:
ProgramID
ProgramCode
ProgramTitle
tblFund:
FundCodeID
FundCode
FundTitle
There’s a many to many relationship between the previous two tables. Therefore, I setup a junction table.
tblPrgFund:
ProgramCode
ProgramTitle
FundCode
FundTitle
(These are lookup fields to their respective tables so I believe Access pulls their key as well which would be the ids)
Now main form is set to tblPR and subform is set to tblPrgFund. There are two comboboxes in subform for FundTitle and ProgramTitle respectively. Requirement is to filter ProgramTitle based upon FundTitle that is selected by user.
To do this I tried the following SQL command in VBA for gotfocus event of program title combo box. But it is only displaying ProgramID and not ProgramTitle. I don’t even think the ids are correct tbh.
"SELECT ProgramID, ProgramTitle FROM tblPrgFund WHERE FundCode = " & Me.FundCode
If I am understanding your dilemma correctly, you want something like this:
"SELECT ProgramTitle FROM tblPrgFund WHERE FundTitle = " & Me.FundCode
OR (if you wanted to use the FundCode, and not the FundTitle)
"SELECT ProgramTitle FROM tblPrgFund WHERE FundCode = " & Me.FundCode
NOTE: This assumes that your FundCode and FundTitle are unique values in your data. But you shouldn't be grabbing the ProgramId, unless your intention is to use it in some way.
That being said, I would highly suggest you use After Update instead of GotFocus as your event for this type of update. Since this is a drop down box, I would assume you don't want the updates to go just from the initial selection of the Combo Box, but rather start after a selection has been made.
Related
I've got two tables that contain the following.
Table Name: Enquiries
ID
Username
Date of Raising
Time of Escalation
Invoice
Repeat Contact
Query Type
Context of Query
DC
Table Name: PC
PCID
PCarea
Town
DCArea
DCName
I currently have a Form setup with the above fields all selected. I have PCArea setup as a drop down as the field has 2000+ records (Postcodes). What I want is when a person updates this field/drop down/combo box for Access to lookup the PCArea and find out what the DCName is relevant to this and then populate the DC field in "Enquiries" and show on the form but I can't fathom how to do it.
I know it's VBA related but I can't seem to get the format right?
Private Sub Combo472_AfterUpdate()
Me.PCArea = Me.Data.Column(9)
End Sub
Sure didn't work! Any help would be great.
Replace {PCAreaDropDown} with name of your dropdown box, and all you really need is the one field in there. It looks like you threw at least 10 columns (9+1) based on your example.
me!DC = dlookup("DCName","PC", "PCArea = '" & me!PcAreaDropDown & "'"
I have a couple of tables in my database.
workout_moves - ID, workout Type, Exercise, Reps
session_moves - ID, Exercise(from workout_moves table), Weight, Notes
I have created a form called workout session which has created a subform for the session_moves table.
The session_moves subform looks like this :
This is fine -but when I select my exercise from the list, I want it to autopopulate the associated Reps value from the workout_moves table rather than forcing me to pick from the list, which is not quite what I would like.
As you can see in the workout_moves table, each exercise is matched to a reps column so this should be pretty easy:
I just cannot work out what the "Row Source" should be for the Reps column in this form in order to auto pull in the data associated with the selection in the Exercise column. Please help.
Set the control source to
=Dlookup("Reps";"workout_moves";"[workout Type] = '" & Nz(cboExercise;"") & "'")
in the Reps control. cboExercise is the controlname of the exercise combobox.
Think about changing foreignkey in table session_moves from Exercises to ID (use primarykeys as foreignkeys).
I have a table named "customers", and a table named "cases". These relate to real estate transactions. On the table "cases" I have a field for "other party", which lets you enter a new customer or pick from an existing one if we have already had that person in our database from a different transaction.
I have created a form with a listbox so I can search all the case records via the customer and other party fields (I also show some other info about the case but am not needing to search that info). In formview the listbox shows the customer name, but only shows the ID number for the other party. When I go to the rowsource, buildevent, and see the query in datasheet view, the records display the way I want them to -by name, not showing ID numbers.
Why won't it display correctly on the listbox??? Please help! I have spent way to many hours trying to figure this out :( This is my first time using access and I am just figuring it out as I go.
this is the SQL from the query in the listbox rowsource:
SELECT Query3.Customers.ID, Query3.[Last Name], Query3.[First Name], Query3.[Other Party], Query3.[Property Address], Query3.[Assigned To], Query3.Lawyer FROM Query3;
and this is the SQL from Query3:
PARAMETERS [ [forms]]![FRM_SearchMulti]![SrchText] Text ( 255 );
SELECT CasesALL.*
FROM CasesALL
WHERE (((CasesALL.[Last Name]) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*")) OR (((CasesALL.[First Name]) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*")) OR (((CasesALL.[Other Party]) Like "*" & [forms]![FRM_SearchMulti]![SrchText] & "*"));
Listboxes and combo boxes have a hidden column feature, usually a primary/foreign key of underlying table. Users generally do not know which primary key they should pick, hence the connecting name/item displays for their selection. Your situation sounds like the key is not being hidden but displaying and with two columns designated, you do not see the Other Party field.
To fix, under Property Sheet / Format Tab of the listbox, adjust Column Count and corresponding Column Widths according to your query (i.e., recordsource of listbox). As shown below the first column of query is hidden with 0 inches of display while the next two fields will display at 2 inches:
Column Count: 3
Column Widths: 0"; 2"; 2"
...
List Width: 4"
Be sure column widths add up to your List Width or there will be cut-offs. Also, inches are automatically added when you enter numbers. Finally, do note the data value of the listbox will be whatever is designated in Bound Column under Property Sheet / Data tab:
Bound Column: 1
Usually, the bound column is the hidden field or it wouldn't be hidden or used!
You probably miss to set columnwidth(s) of the listbox to: 0
I have a lookup field in my table based on another table. I'm having trouble filtering those values based on another field that is entered prior to the field.
Is it possible to filter a lookup field based on another field?
EDIT
Let me try and clarify my original question, sorry about that. Ok, so I have a table1 that has the following fields: ID, Name, Logo.
If a user enters a specific name in the Name field, when they click on the Logo field, it'll only display those values associated that are similar to the name entered. Does that make any sense? If it does make sense, would there be an easier suggesion on accomplishing this task?
If you're talking about inside a table, the answer is "No". You can create cascading combo boxes on a form, but you can't base a lookup value in a field of a table off of a different field in that table (or the field in any other table).
Here is an example of how to handle filtering a combo box based on the value selected in another combo box:
I have the following form:
The combo boxes are named cboIntPN and cboManPN.
The Row Source for cboIntPN is set to: SELECT uniq_key, part_no, revision FROM inventor. The Row Source for cboManPN isn't set to anything.
When the user selects a value for Internal PN the following AfterUpdate Event is triggered:
Private Sub cboInternalPN_AfterUpdate()
[cboManPN].RowSourceType = "Table/Query"
[cboManPN].RowSource = "SELECT uniqmfgrhd, mfgr_pt_no FROM invtmfhd " & _
"WHERE uniq_key = '" & cboIntPN.value & "'"
End Sub
It sounds like he is having the same issue as me. I also wanted to filter a field in a table for data entry on another field's input and my conclusion is "it is time I stopped entering data manually in tables and begin to create Data entry forms. I was putting this task off until later, but if I don't do it now, I might make worse trouble for myself later.
Btw, what an old thread.
I currently have a form which contains a seperate combo box that is related to each table I have created.
These include:
- Business Process Area
- Title
- ReportDescription
- ProcessChain
- MultiProvider
- InfoProvider
I'm having multiple issues, but for now I'll just narrow it down to the one.
I want the form to autofill if you select a lower combo box, so for example if you select a Report Description it will fill Title and Business Process Area. I am using DLookup to do this currently and this is working fine. The issue occurs further down the form.
There are many-to-many relationships between ReportDescription and ProcessChain as well as between ProcessChain and MultiProvider. So currently you can select a MultiProvider, and it will just select the first ProcessChain and keep filling the form from there.
My Current DLookup code on my bottom combo box is:
If IsNull(cmbMultiProvider) Then
cmbMultiProvider = DLookup("MultiProviderID", "MultiProvider", "MultiProviderID =" & Me.cmbInfoProvider.Column(2))
End If
If IsNull(cmbProcessChain) Then
cmbProcessChain = DLookup("ProcessChainID", "ProcessChainMultiProvider", "ProcessChainID =" & Me.cmbMultiProvider.Column(2))
End If
If IsNull(cmbReportDesc) Then
cmbReportDesc = DLookup("ReportID", "ReportDescription", "ReportID =" & Me.cmbProcessChain.Column(2))
End If
And so fourth.
So I would like to replace these DLookup statements with something that will stop at the combo box if the selection below relates to multiple of the field above, as in if a MultiProvider selected in a combo box relates to many Process Chains then the combo box will drop down and only contain the related fields.
Thank you in advance for any help.
So you're going "backwards" up the cascading combos? That is, in most cases you would select these items in descending order, but you're moving up in Ascending order. For example, if you wanted to drill down to an automobile, you generally first select the Year, then the Make, then the Model, etc etc.
Instead, you want to select the Make, and have the Model auto-populate (assuming there is only one Make for that specific Model), and then have the Year left blank (since there could be several Years for a Make and Model).
If so, can you tell us more about your data structure? How are Report Description, Process Chain and MultiProvider related in your tables?