Query subform, not working when used through navigation form - forms

I'll keep this as clear as I can:
My database has two tables:
Clients
Contacts
They have a relationship: For each client (Which is a company, for your understanding) there can be any number of related contacts.
The database has three relevant forms:
SearchFrm
NavigationFrm
ContactsSubFrm
SearchFrm is a form that reads from the Clients table, and has a combo box that, according to chosen record (name), displays all it's other fields in their respective text boxes.
Inside SearchFrm, ContactsSubFrm appears as a datasheet subform, that displays all contacts related to the chosen record in the form, (using a query of Contacts.[Workplace ID])=[Forms]![SearchFrm]![ID]
NavigationFrm serves as a means of navigation between forms. For now, it's only for SearchFrm, but more will come.
And now, the problem: The query that ContactsSubFrm runs doesn't work inside NavigationFrm, when run, I get an input window for [Forms]![SearchFrm]![ID] every time it's suppose to run. This only happens inside navigation.
I'm pretty sure this is because the SearchFrm form itself is closed, and has a problem working through a navigation form, but I can't think of a solution.
Thank you very much.

I was looking for the answer to the same question, so I thought I'd put my solution here in case anyone else comes looking for it...
As stated above, you have to reference the field within your form within your navigation form in your query (as opposed to just the field within your originally created form.)
The best way to do this is:
Open your navigation form.
Open any other form.
Access the expression builder from the other form.
Find the field in your navigation form that you need to reference. Mine looked something like this:
Forms![NavigationForm]![NavigationSubform].Form![Field]
Copy and paste into your query

Since your form moved location (now inside a navigation form), You could try to modify your query from: [Forms]![SearchFrm]![ID] to: [Forms]![NavigationFrm]![SearchFrm]![ID]

I solved this by changing the reference in the query itself to
[forms]![frmNavigationForm]![NavigationSubform].[Form]![ID]

Related

Open form to record seleced from double click on same record in datasheet form

I've got a pair of forms that are both based on the same data table. One is a single form with a better layout of all the onfo, the other is a datasheet. I want to be able to double click on the project number in the datasheet form to open the details single form to that same record.
I've done it on a simplified practice db, but when I try it in my current db it opens the second form, but to a new record entry. This form is one that was a template that someone else downloaded and modified for our purpose, so maybe there is something stored somewhere else that is interrupting the filtering.
I deleted a couple of macros that I thought might be interfering, made sure that the form properties are cycling all records and that on form load it isn't directed to a new record. I can't figure out where else there is something preventing the form from being filtered for the selected record. Here's the code I've used in the datasheet form:
Private Sub combined_DblClick(Cancel As Integer)
DoCmd.OpenForm "frmTaskDetailsExisting", acNormal, , "SLRtaskID = " & Me.SLRtaskID
End Sub
Anyone have an idea what I'm missing here.
Have you considered doing this with a split Form? You will have the Detailed view per record and the dataseet.
If you really want two independent forms due to your needs, your code looks ok. But two things may be happening:
The value in Me.SLRtaskID is not correct. Put a breakpoint in the code and check it.
There is code in frmTaskDetailsExisting that moves it to a new record when it is opened, regardless to the filter.

Move to next record recordset after query in access vba

This is my first question but I have to say that is not the first time that I've used the site. One more thing, sorry for my english...
I'm working on a project in Access 2007 with a lot of VBA code and a lot of forms to the front end. In the forms I've included record navigation buttons for the user to move between the different records of the table (next, previous, etc).
However, I have a problem I do not know how to fix. Imagine that the user enters a form. Naturally, the form shows the 1st record contained in the table. In the form, the user can search a record and go to a specified record.
After getting that record, the user presses the button to display the next record. However, instead of going to the next, it goes to the record after the 1st. In other words, the form goes to the 2nd record.
I guess it's because recordset of the form hasn't been updated, so when the user presses the next button (actually I am doing a docmd.gotorecord acNext), it goes to the next record that is in the table (the 2nd record).
I tried updating the recordset after making the query though the form recordsource method, but nevertheless it continues to go wrong ...
What would be the most practical solution?
Thanks!
Your issue comes from the fact that when you set the filter to false, you actually re-set the entire form.
To get around this, you can try this for your search command:
DoCmd.OpenForm "Customers"
' This assumes that you've got a control on the customers form named ID which has the IDs in it
DoCmd.GoToControl "ID"
DoCmd.FindRecord Me.search_customers_subform.Form.ID
And when clicking next, all you need now is:
DoCmd.GoToRecord , , acNext
The filter doesn't exist anymore.
Hope this works for you. I don't have Access on me right now so this code is mainly from memory, if there's any problems, feel free to ask.

Run VBA code after form load

I have this continuous form "Results" built on a "Search" query in Microsoft Access and I want to show a hidden text field "Number" (with its Visible property initially set to False) depending on the value of one query result written in a "Type" combo box. My code is currently as follows:
Private Sub Form_Load()
If Me.Type="Reclamation" Then
Me.Number.Visible=True
Else: Me.Number.Visible=False
End If
End Sub
This does not seem to work, however the code does fine when triggered by a change event. Adding, changing and deleting records are also disabled in "Results".
Should I run code from a macro, on the query or try another event (I've tried many events though with no success)?
Thanks for the help, and sorry for the noob question!
Continuous Forms behave differently than what you think. It cannot work with UnBound Controls. If the control Number is bound it will take effect on only the Record that has foucs. Using Form Current combined with Load should/might work, but again it will not be the best solution. Because it will be applied to all other records in the SubForm.
Example of what I mean is, if the form has three records. First Record has Type (a terrible field/control name) "Reclamation" then the "current" record's Number (again a very bad field/control name) will be hidden along with all the other record's Number, even if they have other Type's in their record.
I would suggest you to go with Single Form.

Form visible in Design View, but blank in Form View

My form is showing up in design, but not form view. There are 700+ records.
In Design View -> Data, the Record Source is:
SELECT act.* FROM act;
This query shows all records in Query view.
There are no filters, and Allow Form View is set to Yes.
What is causing my form not to show?
EDIT: I'm noticing that the form is extremely wide. There isn't a width setting, but in Design view with window maximized I have to scroll way over to see the right edge. Would this have anything to do with it?
This link might help you. I remember having this issue and it was because of a read-only query.
Why does my form go completely blank?
Here is an excerpt that lists the main conditions why this could happen:
Condition (a) can be triggered in several ways. Examples:
- The form's Data Entry property is set to Yes. (This means the form shows no existing records, i.e. it is for entering new ones only.)
- The form has a Filter applied (or is opened with a WhereCondition) that yields no records.
- The form is based on a query where the criteria yield no records.
- The form is based on a table that has no records.
Condition (b) can be also be triggered by several things:
- The form's Allow Additions property is set to No.
- The form's Recordset Type property is set to something other than Dynaset.
- The form is based on a read-only query. (If you cannot add a record directly to your query, see Why is my query read-only?)
Auto_title_0 was set to 21" wide. Resizing that to the actual form width solved the problem.
On Design View of the Form click on "Details" which is just below the ruler and make sure that Visible is set to Yes on the Property Sheet.
Try this step.
Click to select Form.
Click on Auto Resize.
Change value to Yes.
Look into this
I also had the issue with a Form I used to input the strings for a query. The problem was that there were no records to answer query as I had changed it to an "Select Distinct" query to get rid of duplicate answers, but it also eliminated new record sets. Deleting the "Distinct" in my SQL solved the problem. Thanks for your help!
For me - the Form.Data Entry property was set to Yes.
Changing it to No shows the form again.
As for my case, I had open two forms.
Form B is link to Form A.
When Form B is opened, Form A is blank because it does not allow for data to be added.
When I close Form B and re-open (or refresh) Form A, the form fields appear.
Hope someone finds this helpful.. I faced this problem and solved by changing Pop On property (under the other tab) to No, and also changing the border style to "Dialog" in design view mode.
I also had this problem which wasted lots of time, but I was able to fix it.
The reason for me was that my target table was empty and I had primary keys set on it and had my controls in my form related to those fields.
So, Access was unable to show blank primary keys and was not displaying the form at all.
If you fill up your target table with some data, save and close the form and open it again the controls will be displayed.

How to make a field "autocomplete"?

I can't figure out how to make a field autocomplete in ATK.
I guess it has something to do with the type "reference" but still not sure.
Suppose I'm looking for a client name in a "line" type field, then the autocomplete should list me all/topXX matching names.
Scenario 1:
Once I hit [Enter] I'd need all that row from DB loaded in a form fields so I can edit the record.
I guess this requires getting the client ID first then posting to an "edit" page then calling "loadData()" method for that ID and populate fields.
Scenario 2:
I'm assignig a job request to a client. First I find the client then I could store its ID in a hidden field to be posted then.
Any advice?
TIA
I would suggest you to go with 2 forms. First form with a single field, and when field is changed it automatically reloads second form including the parameter.
You will also need an autocomplete field. Autocomplete is somewhat buggy in 4.0, but it have been polished up in 4.1 by using a technique in http://jqueryui.com/demos/autocomplete/#combobox
For use with models and controllers and also dropdown, example is here:
http://codepad.agiletoolkit.org/reloadform
Alternative example:
http://demo.atk4.com/demo.html?t=22
Since 4.1, you can also use autocomplete fields instead of reference:
$form1->addField('autocomplete','user');