How can we open specific form based on what we click in the combo box? I tried using macro but it only can be used for 1 value of the combo box only (cannot assign specific form for all value of combo box)
Goto to Combo box properties and select Macro builder
Using Macro you can define all conditions and respective actions.
Related
I've got an Access Form with a combobox bound to a query that selects 2 fields. I managed to get the combobox showing up the query's second column by setting up in the combobox's Property Sheet the following: Column Number = 2 (with the first column width = 0); Bound Column = 1 (because it contains a value input for another query).
My problem is that when I open the Form, choose a value from the combobox and then save the Form as a Report, the combobox goes blank! In the Report I don't find the value previously selected for the combobox in the Form.
How can I fix it?
It appears you are looking to give the end user the ability to print what they see on the data entry form. But in access the printing functions are attached to reports. So we need a report that looks like the data entry form and some way to access the report from the data entry form. So add a print button or some such that will open the report. The report needs to look like the form so saving the form as a report is a good jump start but then some comboboxes don't show. Skip to the end for an explanation why. So we have to set the problem report comboboxes manually. One way is to pass parameters to the report when it opens:
Private Sub PrintButton_Click()
'look up DoCmd.OpenReport if you want to do something other than print preview
DoCmd.OpenReport ReportName:="ReportSavedFromForm", OpenArgs:=OriginalformComboBox.Value, View:=acViewPreview
End Sub
Private Sub ReportSavedFromForm_Load()
reportCombobox = Me.OpenArgs
End Sub
As to why the combobox is blank or stuck on the first value, according to the following link reports are not supposed to be used for editing data.
https://social.msdn.microsoft.com/Forums/office/en-US/14c6ec9a-53bd-4546-ba0e-597c41ca7cce/combo-box-drop-down-arrow-invisible-on-reports?forum=accessdev\
So the combobox dropdown arrow will not appear by design. I put this to the test in office 2016 and in the report header and report footer sections the combobox appears blank if the combobox is unbound. If the combobox is bound say to an ID the combobox behaves a little differently. It shows the first record but is just a textbox with no drop down arrow so only the first record ever shows. However in the details section while you still don't have the dropdown arrow the combo box still can be used to replace an id with a more friendly value
I am working on an MS Access Form. I am trying to have a Combo Box on the form who's list is narrowed based on information earlier in the form. I have a Query saved in the database that gets the list properly.
The problem I am having is that the query is not called after each update of the form so the Combo Box's list is always what it was when the form was opened.
I have tried to force an update using Me.MyComboBox.Requery in the AfterUpdate event of the previous control but this only requeries the record source of theform, not the row source of the Combo Box.
I have also tried changing the row source property to force a requery but that did not work eithier:
Private Sub PreviusControl_AfterUpdate()
Me.MyComboBox.RowSourceType = "Table/Query"
Me.MyComboBox.RowSource = "qryDynamicComboSource"
End Sub
Thanks in advance!
It looks like everything you're doing is correct. Check your query design if it's actually changing based on your parameters.
I do have an unbound search form, in which a listbox is filled with search results. Upon selection of one listbox item and click on a button "view details" the bound form RSdetails is displayed
30 DoCmd.OpenForm "RSdetails", , , "[ID]=" & selectedID, , acDialog
The bound form RSdetails contains an unbound subform RSmails. All controls in subform RSmails are unbound as well.
The intention of this subform is to establish a connection to a Lotus Notes mailbox and to perform a search for mails containing a certain key.
The subform has 2 dropdowns to select the view and the range of time to search in, 2 buttons (search and abort) and a listbox to display the matches.
Now if I open this form RSmails directly I can make selections in the dropdowns and click the buttons.
If this form (RSmails) is viewed as subform of RSdetails I can NOT make any selection. The dropdowns and buttons are enabled, but show no reaction.
What I already tried, but failed to succeed:
open RSdetails in acWindowNormal instead in acDialog
bind RSmails to a table which has a relation to the table RSdetails is bound to and definitely has a recordset with the selectedID
Any idea is appreciated!
Thanks,
Thomas
Apparently you put the subform with lock edition. Check the properties for the subform (into the form) and verify that:
- Can add? (i think must be NO if you have all content created into)
- Can Delete? (i think must be NO because only to read records)
- Can Edit? (i think actually you have NO and must be YES)
Conclusion: The problem was solved by exporting every table/ table-link, form, query, modul to a blank new project. The problem disappeared, the app works like expected.
Did not find the real reason, but according to above work around, it looks like an undefined hick up in Access.
MS Access 2007, Win 7 32-bits
Is there a way where I can access an open query in datasheet view in access to get the current field value and current field name?
I won't put it into a form since it is a crosstab query and i'd have to generate and get rid of controls dynamically but i'm not fond of messing with forms controls that way with VBA. I know i can put a dynamic column report and bind an event on the controls but I'm asking if there are events or objects that can let me access directly the query.
Perhaps a recordset clone? But I haven't find anything on google.
Of course this is in VBA
Best regards,
It may be possible to work around your requirements. The crosstab is contained by a subform:
Source Object : Query.xtab
The Control Source for the two textboxes is:
Ctrl : =[screen].[activecontrol].[name]
Content: =[screen].[activecontrol]
Which means they show which ever column ans column contents the user selects in the crosstab subform. However, they will also show any other selected control on the form. ClickMe does not change the selected control, so the selected items remain the same in the textboxes.
You can also enter MacDermott's code for getting the current control's index, so the current control selected on the xtab query subform is displayed dynamically
Public Function ControlIndex(ctl as Control) as long
Dim i as Integer
For i=0 to Me.Controls.Count-1
if me.Controls(i) is ctl then
ControlIndex=i
exit for
end if
next
End Function
And finally this can help when changing from one control to another in the same record to keep the textboxes current.
I want a Access parameter query to ask an user for a value (a location in this case). When I type [Enter location] in the Criteria field it works fine: I get a dialog box (Enter Parameter Value) with a textbox and my text (Enter Location). So far, so good. This works (the result also).
But now I want a dropdown/combobox (instead of a textbox ) for the user to pick a location. I made a form and type Forms![Form1]![CmbLocation] in the Criteria field.
Like this: http://office.microsoft.com/en-us/access/HA011170771033.aspx
But I still get a textbox (with the reference as textlabel).
What am I doing wrong? Has anybody any advice?
In addition to Albert's suggestion, you might want to make this work within the query itself, so that it's "bootstrappable." To do that, you'd have to write function that returns the value chosen in the combo box on the form. It would be something like this:
Public Function ReturnMyCriterion() As Variant
DoCmd.OpenForm "dlgGetCriterion", , , , , acDialog
With Forms!dlgGetCriterion
If .Tag <> "Cancel" Then
ReturnMyCriterion = Nz(!cmbMyCombo, "*")
End If
Else
ReturnMyCriterion = "*"
End With
Close acForm, "dlgGetCriterion"
End Function
(when opening a form with the acDialog switch, the code pauses as long as the form is open or visible; to get the value out of the combo box, you have to set the form's .Visible property to False. You could do this in the AfterUpdate event of the combo box, or in the OK button. You'd also want a Cancel button that set's the form's .Tag property to "Cancel" and then sets the form's .Visible property to False; this is all relatively a standard approach to working with dialog forms in Access).
You'd then make the criterion in your query be:
Like ReturnMyCriterion()
That is, assuming you want to return all records if no value is chosen in the combo box.
If you removed parameter form your query, and then re-typed in the above form exprsison into the query builder, then it should work.
So, in the query builder, in the criteria section just type in
[forms]![form1]![Combo4]
Make sure you have the right form name and control name of the combo box.
You should not need to type in anything else into the query builder. As mentoned, remove the old parameter prompt you previous had in the query builder.
Now, open the form, select the combo box, and now try opening the query, it should open without any prompts. Note this approach means that the form will have to be open, and the combo box will have be selected a value BEFORE you attempt to launch the query. So, if you basing a report on this query, then palce the button to launch the report on the same form as the one with combo box. This quite much ensures that the form will be open before you attempt to launch a query or report that is based on that query