How to choose custom quantity for each record row in Bartender? - sql

I have the following template set up on bartender
Product Code: Barcode: Quantity:
0001 1234 0
Idea
The page is set up with 1 column and 3 rows. Next, select maximum of 3 records from record picker. The 3 records chosen will then be automatically filled out onto the page.
(Records are from SQL Database)
I have a form set up with a record picker. If I choose 3 random records from the database. The output would be something like this:
Product Code: Barcode: Quantity:
0001 1234 0
0002 1235 0
0003 1236 0
My Question is
when pressed Print. How can I adjust the quantity for each record?
Images:
Data Entry Form
Data for each row
Page template

There are two solutions for your problem. The first and my preferred is to add a column for quantity. Simply right click on the record picker and choose properties. go to the tab Record Picker and search for the option "Selector Column". If you change this to Quantity, you will be able to add a unique quantity for each record and you can remove the number input box.
The second solution is to use the number input box. Simply linking it to the copies field should do the trick but you will need to run the form multiple times to print every record since it will close after every print. To link the field just look to the left side of the screen when your in the form builder and drag "copies" on the number input box. To solve the issue of the form you can use an option "repeat data entry until cancelled. This will reopen the print form until you close it. you can select this option in the print screen (ctrl+p) and select Options in the lower half of the screen. Select the option "repeat data entry until cancelled" and you're set.

Related

My query, getting value from a textbox inside a subform, shows "small box"

The overall scenario: Actually trying to implement an order entry
system. A button on the main form opens 2nd form. In the 2nd form,
there are some combo-boxes and list-boxes from which the user selects
an item. Then pressing a button add that item with append query.
The problem is, as soon as I click anywhere in the 2nd (child) form;
the the id (autonumber) from parent vanishes(becomes null) for new
entry in the 2nd form. (I have lately discovered this vanishing by
using a text box to show current parent-id. Also found a solution,
posting as an answer)
I am trying to get two values from a textbox and a combo box. In the query datasheet view, i checked that, one value is received correctly but the other value it shows a very small box (putting picture below)
)
In this picture, "Expr2" field is showing small box. I used below statement to pull value from subform:
Expr2:[Forms]![customer_f]![products_add_subf].[Form]![customer_id]
And here is the code in sql-view:
INSERT INTO products_t ( product_name, customer_id )
SELECT [Forms]![customer_f]![products_add_subf].[Form]![item_combo] AS Expr1, [Forms]![customer_f]![products_add_subf].[Form]![customer_id] AS Expr2;
What this small box mean and how to avoid it ? How to pull correct value instead of small box ?
The solution will prevent vanishing of parent-id from first form(parent); in the 2nd form (child).
Just disable "Allow Addition" in the 2nd form's property.
Steps:
Open the 2nd form in "design view" . Double Click at the upper left corner of the form to open its property sheet. Goto "data" tab. In the "Allow Addition" select "no".
Now your append query will be able to grab the parent id field. It will not vanish !

Access VBA reselect items in List Box

I'm working on a DB where the users have to select items from multiple list boxes, at the end of the all of this, the form closes and opens a new form. All of that works great.
My issue is that when the user goes back to the original form, I want it to load in with their list box items already highlighted. Sort of a "here is where you left off" kind of thing.
I have code that works, but it's somewhat limited:
If InStr(me.Backup_Chain, "Apple") > 0 then
Me.List_Type.Selected(0) = true
End if
If InStr(me.Backup_Chain, "Grapes") > 0 then
Me.List_Type.Selected(1) = true
End if
"List_Type" is just a textbox that I populate with the users previous selection. So if they selected Apples and Grapes it reads: 'Apples','Grapes'
This works pretty well, but it's not dynamic. So if I add "Bananas" to the list, Bananas because item number 1 in the list, and thus screws up all of my other references.
So, my question is 2 parts:
Is there an easier way or reselecting the list box items?
If not, is there a way to make the Selected(#) dynamic? i.e. to tell that "Grapes" is in location 1 vs 2.
Thanks everyone!
Edit: In addition to this, I have a run a query to filter one of the list boxes down to a subgroup of clients (based on the other list box selections). Which means I need to refresh the page. So I can't get by with just hiding the form.

How do I validate a Form input field with a Table row value in microsoft access?

I am having issues with setting a Validation rule in Access.
I have a database with the tables Clients, TypeClient, Sales, SalesList, Items.
I have a form for Sales, with a sub-form SalesList inside which has a relationship with Items in order for me to put several stock items in Sales instead of only one item.
Inside Sales table is ID, Date Sold, ID Client.
Inside SalesList is ID_List(referenced to ID in Sales), ID_Item(referenced to ID in Items), Quantity.
Inside Items is ID, Name, Stock(how much we have in stock), Price
The issue is that I am trying to validate the data I enter in the sub-form Quantity field to be higher than 0, but no higher than the available stock.
The issue is that I have tried using the expression builder to get the value from a calculated query that has 2 fields - the ID and the value for that id, with criteria that is for the ID to get it from the main form, the sub-form, the combo box input and the query works.
But when trying to get it like this:
It shows an error "The expression [Query bla] you entered in the form control's ValidationRule property contains the error The object doesn't contain the Automation object 'Query bla'".
I tried using directly the table Value(but it won't work anyway as it doesn't know for which field to get the stock value from), still the same error. I guess it can't reference to anything else? Normal validation rules work, but I want to validate it not to exceed the value of the available stock for the item I am selling now.
Nowhere on the internet there is a tutorial how to do it with expression builder. How do people validate their fields then?
It doesn't stop me in this case to sell 200 items when I currently have stock of only 2 of them, for example.
Note: I have tried DlookUp in expression builder, straight up tells me No.
Sample wrong validation rule expression builder code:
<=[Query bla]![Stock]
<=[Items]![Stock]
I am currently using VBA and fetch the record I need(the current stock) with one of the following and my unbound text is changing on every subform to the same, it shouldn't happen like that. What can I use to populate a field for each record uniquely:
Private Sub ID_Product_IZBOR_Click()
'Me.Stock_ValueField = DLookup("[Nalichnost]", "Stoka", "[ID]=" & Me.ID_Product_IZBOR)
Me.Stock_ValueField = Me.ID_Product_IZBOR.Column(2)
End Sub
Partial solution: I created a new Dim as Integer and fetched the records based on the ID provided by the field in the form and used BeforeUpdate to validate the current stock. Unfortunately the only way to see the current stock level is to click on the combo box where you choose your product and check the column for that one, it doesn't show anywhere else :(
Don't use the expression builder (I NEVER do) - just type the needed expression in property.
>0 AND <=DLookup("Stock", "Items", "ID=" & [ID_Item])
Another approach is to return Stock in textbox ControlSource then ValidationRule references that textbox. Also, user can then see the quantity limit. Methods of pulling the Stock value from Items table:
include Stock field in Items combobox RowSource - textbox then references column by its index (index begins with 0): =[cbxItems].Column(2); VBA may be needed to Requery combobox after record entry/edit is committed to table.
include Items table in form RecordSource - bind textbox to Stock field (Locked yes and TabStop no)
DLookup() expression in textbox ControlSource
Use ValidationText property to give users a custom message.
However, ValidationRule will not prevent user not entering any value if they skip the control. If you want to make sure a value is entered, either set field as required in table or use form BeforeUpdate event to validate record data.

(Access) search text field for strings matching those in another table's field and display these matching records in a subform

Here's my situation,
tbl_products / frm_products
ID__products
products__name (short text)
products__description (short text)
tbl_articles / frm_articles
ID__articles
articles__name (short text)
articles__body (long text)
I have a form bound to tbl_articles containing a subform bound to tbl_products.
What I would like to happen is,
once a user enters text into the articles__body field, (using the After Update module)
it searches this long text field for any words which match a product name
and then (in the subform) displays the matching products.
For example if the articles__body record that the user is currently viewing contains 'product 1', it will display product 1's record in the subform.
Perhaps After Update is not appropriate as it needs to appear to remember these matches. For example, if tbl_articles' record 1 matches/displays product 1 on the subform whereas record 2 matches/displays products 2,3 and 4; I need the user to be able to revisit record 1 and see the product 1 match without having to edit the text (and trigger the After Update).
I have no idea where to start with this. It's not a simple if string contains, Originally I entertained the idea of something like - Like '* [in tbl_products, record 1's products__name] *' repeated for each record (obviously not the correct syntax but simply identifying the process to myself), however this is impractical because the number of strings to match against will grow over time as more products are added.
Any help would be great,
Kind regards
Set Filter and FilterOn properties. Suggest naming subform container control different from the form it holds, like ctrProducts.
Me.ctrProducts.Form.Filter = "InStr('" & Me.articles_body & "', [products_name])>0"
Me.ctrProducts.Form.FilterOn = True

Change values in form depending on a single element

I have a form, wich uses a query as source:
SELECT
[UserName],
[WBS_Id],
[Koptekst]
FROM
tbl_New_WPE_User
WHERE
[UserName] = funcActiveUser();
On the form I currently have 2 elements (probably more later)
In the dropdown menu, I want the form to show all WBS_id's that are assigned to the current user.
However, when i select the dropdown list setting and input WBS_Id as control source, it only shows 1 WBS Id.
what I would like to accomplish, is seeing the data in the comment field (the large box to the right) change when I change the WBS id in the listbox
Edit: If I run the query, this is the outcome: