How can i sort checked checkbox items and send them to labels in vb - vb.net

i want to write a mechanical eng. software to calculate kitchen hood exhaust flow rate and make a report.
firstly, user will check the calculate button, secondly user will check gas or electric and then user will enter the area.
for example, user select two random types(there are 40 types of kitchen hoods) and selects gas and enters areas. i will make calculation from these selections but my problem is: i can't write them to second form with sorting the selected ones.
you can see label 1, label2 etc. i can send the selected box text to labels with if statement:
If CheckBox1.Checked Then
Form2.Label1.Text = Label5.Text
End If
but i don't know which one will selected and i will have 40 types but in report part (form2) i will have maximum 10 types(because of the general layout of kitchen designs). so i want to sort selected ones and add report form without any blank rows.
i'm really sorry for my poor English.

Related

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.

Adding multiple textboxes to a form in ms-access?

I would like to have a line on an Access user-form. Call it Item #1. I would like Item #1 to be a text box where the user can enter any type of information. So for example, say the user entered "Tutoring" and then next to this was an additional Textbox that allowed the user to enter the hours spent tutoring and the date in which the hours were logged.
What I would like is to have a button to allow the user to add a second line (or set of textboxes) when needed, or a third line, etc. Is this something that can be set up on the Access form? Does this need to be coded in VBA? Just looking for some tips to provide me some direction on the best approach.
"If the data should not be stored in a table, it' a bit more complicated. "
You would have to make the text boxes not visible when the form loads, and then make each text box visible on the After Update event of the previous box.

Crystal Reports - Prompt for Total Page Count

I have a report that I'm using to create individual shipping labels for product delivery. Company Name, Address, additional fields are all straight forward and drag and drop into report, requiring little manipulation.
My issue comes about in trying to determine how I can prompt the user for the quantity of labels needed for print. This will change from shipment to shipment based on how many boxes are required to fulfill the order. Each box requires its own shipping label. I would simply have the user specify quantity at the "copies" section of the print screen but I also need a field on the label stating n of m so the customer knows total boxes shipped and has an identifier for each individual box. For this reason, I'm curious if and how I can prompt the user before print to provide "total page count", where I can then create the number of needed documents and increment per label using the "page number" field, creating a prompted n of m function.
"Total page count" and "page number" are special fields that I seem to have little access in manipulating so if you know how I can prompt a user for necessary label quantity "total page count" then increment per label with "page number",(to achieve an incrementing N of M function where M is defined by the user) in this manner or another let me know.
Thanks,
Travis

Two if conditions Visual Basic

I am trying to validate input in this VB program that calculates football stats. If both boxes are empty when a user clicks Update Stats, it should display a message box. However, with this code it shows the message whether both boxes are empty or if they have values entered. Any idea what I am doing wrong?
'validate user input (ensure textBoxes aren't blank)
If passYdTextBox.Text = "" And rushYdTextBox.Text = "" Then
MessageBox.Show("Please enter values into pass yards box or rush yards box")
End If
A better way to check this would be to use the IsNullOrWhiteSpace() method or even doing something like passYdTextBox.Text.Length > 0 as your problem could be due to data types and casting.
I'm sure you have already considered this as well, but this validation alone is not enough to avoid an exception. You will also need to ensure that the Text in the field is numeric before trying to cast the String.

Multiple Text Box and Lookups

I am currently trying to improve on an Access Database VBA that I have inherited from my predecessor at work. I have come unstuck on a particular form.
I have a form that at the moment is just a large form containing 32 individual textbox, with the same code behind each but it is the same code repeated for each textbox with just the references to the text box changing in each.
Private Sub Cand_No2_AfterUpdate()
Cand_Name2 = DLookup("[Name]", "[qryExamAbsences]", "[Cand_No] = Cand_No2")
End Sub
Then once the button is pressed
If Not IsNull([Cand_Name1]) Then
Rope = Rope & " Or Cand_No = " & [Cand_No1]
End If
(The If statement is contained in the button mousedown event.)
Occurs for each text box which then filters a report that is printed for office use. There are many problems with this but the major one I am trying to solve is that there is an upper limit to the number of entries, if I need to filter more than 32 I would need to delete the text and start again as it were.
Is there a way of combining all this into a single section of code which will create text boxes when needed?
EDIT.
I have found a way to give the impression to the user that the text boxes are being created after each entry which has improved the form from a user standpoint (no longer having 32 textboxes or having to scroll down to the Print Button.) however this still hasn't solved the issue of messy code as I have had to repeat the extra code for each box again, it also leaves me with the maximum of 32 entries still.
The new code is as follows:
If Not IsNull(Cand_Name1.value) Then
Cand_No2.Visible = True
Cand_Name2.Visible = True
cmdPrint.Top = 2500
cmdPrint.Left = 2500
DoCmd.MoveSize 1440, 2201, , 4000
Else
Cand_No2.Visible = False
Cand_Name2.Visible = False
cmdPrint.Top = 2000
DoCmd.MoveSize 1440, 2201, , 3500
End If
Essentially makes the next text box visible and moves the print button down to make room for the new text boxes. It also expands the window.
Could you not just have 2 text boxes, one for CAND_NO and another for CAND_NAME and then beside those two boxes place an ADD CAND_NO button.
Create a list box that would list every CAND_NO / CAND_NAME after they press the add button so they can see what they've added so far. Then loop through your list box to build your rope string or have your rope string either a global variable on the form and build it as they add numbers or stored in a hidden text box storing the value as they add numbers if you don't like global.