Bound textbox in main form to lookup query in subform - ms-access

I'm working on a project that involves generating a rental and later being able to return to manage the rental in the future (i.e. return the rental, the bill for damages, etc.
I have a query that creates rentals with an auto number for the id.
Another query creates a list of items for each rental - this query is associated with 2 subforms (one to initially list items in a rental, and one to later return to declare items returned/damaged, etc..)
To manage the rental, I have a form where I want to be able to scan a bar-code equivalent of a rental ID and pass the value to a subform to display the details query (table view) to be able to edit/process rental items. When the textbox is bound, it throws an error stating that I cant type in the field because it is autogenerated. If I leave the textbox unbound, how would I pass the value to the subform to be able to process the rental?
Any input is greatly appreciated!

I suggest you create a new unbound text box and a Search button next to it. The button will have code to filter your subform according value in this unbound text box where user types the ID.

Related

MS Access get number of sub rows in datasheet

I have a little problem here. I've a database with one table for Users and one for changes in progress for these users. They are in a 1:n relationship (one user can have many changes but one change only affects one user).
I output my users in datasheet view and have the changes in by standard collapsed subrows of this datasheet. The user shall be able to order the users by the number of ongoing changes matching the filters in this sub-form. Therefore i have to get the number of rows in this form.
in the subform i have a field called "Anzahl" (german for count) representing the number of elements currently shown in the sub-form and i have a field called SubFormAnzahl in the parent datasheet.
Now i try to access this field via
=[Changes_Subfrom].[Form].[Anzahl]
and i am getting a #Name? error.
Why does this happen and how can i prevent it?
With main form set as datasheet, it can't see subform textbox until subdatasheet is expanded, then the calc shows. If you want to keep main form as datasheet, options are:
set main form SubdatasheetExpanded property to yes.
DCount() domain aggregate function on main form - expression in query used as RecordSource or in textbox and must use same filter criteria applied to subform
DCount("*", "Changes", "UserID=" & [ID])
Otherwise, works with main form in Single view.

How to get combo box selection to fill related fields with data

I have a table [inventory] with inventory items, and a bunch of columns with different information for those. Mainly, part#, description, price. I am trying to create both a purchase order form [POForm] and, and a inventory transactions form [TransactionsForm], but that one thing I've been stuck on is getting a combo box look up I use to select the part# from [inventory], to also fill my fields for description, and price for that item in my form. I need the fields that are filled to be able to have formula's run off of them, and the information to be saved into the table for that form [TransactionsTable], [POTable].
I've tried making my part# combo box include the fields for the description and price, and using =[part#].[column](x) in the other fields as a lookup, and it looks right visually, but that is apparently just a visual of that data, but technically the field is still blank, because those other fields remain empty in the table for that form, and I am not able to run a formula off the price.
As per my understanding and please correct me if I am wrong. you have a form that shows your inventory data Part# Description & price. This form has a combo box that allows you to select a particular part # to view its related record data description and price.
Now you want to click a command button after selecting a particular part # to update your transaction form and POtable.
1.you have to create a query,
2.insert the inventory table in it
3.select append from the query type in the ms access ribbon
4.a window will appear, choose the transaction table as the destination table to append to.
5.double click on the fields that you want to retrieve its data from the inventory table
6.then in the table below in the query itself in the "append to" row you will find drop-down menu including all the fields from the transaction table. choose the corresponding fields. note if the fields have the same name in both tables access will do it automatically.
7.in the criteria row type the following [Forms]![Inventory Form Name]![the name of the field in the form]. do that for each field in the happen query.
8.save the query and name it
9.go-to design view in your inventory form and create a command button, in the click on event creat macro of the following: openquery-->type the append query name
10.save and close macro builder
11.open your form, select part#, click on the button
12.access will ask you to confirm appending process. click ok/yes
13.check your transaction table to confirm that the append process was successfully performed
14.Tip if you do not want the confirmation msg of append to appear, in the click on event go to the macro builder and choose in the ribbon show all actions then in the first line of the macro builder insert setwarnings - NO
the same is to be applied for the POtable.
Anyways, I hope you find this clear and helpful but I have only one concern you do not have to append part description and price in transaction and PO tables as you already have this data in your database in the inventory table. Generally speaking no need to include the same information in multiple tables otherwise you are not benefitting from the idea of a relational database.
I hope I addressed your inquiry.

Access: a Form with 2 subforms (Same table)

I am trying to create a Form of Payments, and I want to split the actives and pasives with two subforms.
I have made it, and works! The table Payments store the values.
The actives and pasives are in a table.
ID -> Number
Description -> String
Pasive -> True/false
I have created two Forms, for actives and pasives. Each form displays the corresponding values.
Also I have created main Form that contains two subforms (actives and pasives)
When I insert a Payment
GREAT! It works!
But, when I open again the form, the values are disordered.
Can you help me?
Thanks!
I'm not sure if it understand you correctly. It looks like your subforms don't know which data is passive and which is active. Try this:
Instead of yes/no field in your table, you could rather create field with dropdown list that allows you to pick one of two values: passive or active. Let's name that field: transactionType.
Then you should add transactionType control to each subform.
In the first subform you set default value for transactionType control as a ="active", in the second subform: ="passive".
Now you can set visible parameter of transactionType controls in both subforms to no. In form view you won't see them, but if you create new record, the will add proper information to your table.
Are your subforms based on query? If no, go to subforms data source, create query based on your table and in the criteria of transactionType field set respectively "active" (in the firs subform) and "passive" (in the second one).
When you reopen
your form, thanks to query filter you have set in step 5, subforms will
display only actives or only passives. If you chose that solution, this will work for new data only. If you already have some data in your table, you should manually complete trasactionType for each existing record.

Split form columns not displaying correct value

I have a split form set up in Access 2007. In it, I have one combo box to select a school, and the After Update event for this combo box populates a second combo box.
The second combo box selects an item of equipment, and the query associated with it selects all equipment located at the selected school, unioned with the currently selected piece of equipment. (If the school selection changed, the box would turn blank, but actually still hold a value, so I unioned it with it's own current value)
Anyhow, the issue is that the equipment column in the split view only shows equipment values that are associated with the currently selected school as well. For example, if I have a form with schoolA and EquipmentA selected, only equipment also associated with SchoolA will appear in the Equipment column of the split form data sheet. If I change the School column to SchoolB, any rows that were populated with equipment associated with schoolA disappear, and equipment on rows associated with schoolB now show up.
Interestingly, if you click on the school column of the data sheet, this also will update the equipment column to only show equipment related to whatever school was in that row.
To summarize: changing the value of one field in my split form will change what data is displayed in the data sheet portion of the form. Clicking on the fields column in the data sheet has the same effect.
I had the same issue, as you describe. I used a workaround (i.e. used different control instead of split-form)
My Situation:since In the split-form, I was just showing the records, and not allowing users to edit the records in split form. Users could click on any record in split form, which would show in main form, and then could edit. The main purpose of this form was for the users to be able to search for the data in split form and then select and edit.
My workaround : Created a form, where I used text boxes to search, and a list view to show all the columns which were in the split form. On double click event, I added Open the form filtered with the record which was double clicked.

Suggestion and auto-complete in form with one-to-many relationship in Access

I am trying to make a form for a very typical scenario: a customer makes an order. The customer might be new or returning. I have created an Access database with two tables: Job and Customer (linked by the primary key 'customer no'). The form I wish to create looks like this:
The customer table data is highlighted.
When the customer's name is beginning to be typed in, I want to see an updating list suggesting possible customer matches. If the customer happens to be returning, I can click on one of the drop-down options and have all other customer fields auto-complete.
What is the best way to create such a form?
I tried to achieve this using a comboBox and some code. However, if I use this method, the comboBox does not allow me to enter a customer name which isn't already in the customer's table. So I can't enter new customer details.
Ideally, this auto-complete/suggestion should work for all customer fields, such as phone number (in case the phone number is the only know customer info).
You could use a combobox which has LimitToList set to false, allowing entry of data not already defined in the combobox's rowsource; With this approach you would define a not-in-list event handler for the combobox to open a popup form for adding a new customer, ideally pre-initialised with the customer name just entered, and when data is saved in that form, control returns to this form, requeries the combobox (as it's contained data is now out of date), re-locks the customer just added, and fires it's after update event to display all the relevant customer-related fields appearing on this form.
However whether this is appropriate or not depends to some extent on the quantity of data that you have. If you've more than say 10000 customers in the database, I'd recommend instead having an elipsis (...) button beside customer name which opens a popup search screen, and provides whatever search options seem best (name, number, city, etc) for the entity being searched, a textbox, and find + add buttons; With huge data quantities you might also want to provide a means to prevent searching for matches (especially by multiple users across a busy network) where there is less than say 4 characters in the textbox, to improve performance.
You'd then use the text_changed event on the textbox to retrieve the data in the database which starts with the text currently existing in the textbox, and display this in a datasheet; The user can then either click Find or double-click the datasheet to select a customer which you then return to the calling form, probably by either a call to a public sub, or setting a tag value on that form - or click Add to add a new customer and invoke logic similar to the above.