vba and outputing data from hidden/Non-enabled multipages - excel

I have a userform with various tabs on a multipage. I am using datepickers (Microsoft Date and Time Picker Control 6.0) and textboxes on the different tabs.
The problem occurs when I want to get the data from the hidden, non-enabled or simply non-active multipages to output to the worksheet.
For example, Multipage1 has a Date of Birth, Multipage 2 has a start date.
When I press the command button to execute the output of ALL data across all multipages to the worksheet, it will only output the value for the currently active multipage. The other values are default.
Mulitpage1 active means it will return D.O.B but returns a blank/default start date from Multipage2
Multipage2 active means it will return start date but returns a blank/default D.O.B from Multipage1
Multipage 3 active means neither D.O.B or Start Date will output anything other than their default values.
(Presume all fields across all multipages have actually been completed with a value)
Is there a way around this?
The command button to output data has a long list of statements like these:
Cells(6, 2) = Address1TextBox.Value
Cells(7, 2) = Address2TextBox.Value
Cells(8, 2) = Address3TextBox.Value

DatePicker was the issue here and I know textboxes do not have an issue with being output to the worksheet while hidden/disabled.
With this in mind I had to resort to using a textbox with validation which only allows the user to enter a date.
Answer = Don't use Microsoft Date and Time Picker Control 6.0

Related

excel VBA question using a button? extracting values from one tab to search into another

I am stuck trying to figure out how to code this into excel. I am trying to use a button in excel to execute some actions using data. it is as follows:
Tab1 is the main page here. Here i have to select a specific number of accounts (up to 10 accounts), and a fixed date from and to. using the command button, i want a VBA code that uses the X number of accounts and the selected dates to search through Tab2, and select all the rows (in this case A:K) that has all accounts that are within the specific dates selected in tab1. so it can then be pasted into tab3. in Tab1, cells B10:B20 are the cells where the user enters the names of the account. Cells B30 is from date and B31 is to date; which are the desired dates the user wants to extract from tab2 and paste into tab3. i mean extract all the rows that contain the accounts within the selected dates.
my main issue is that the command button is kinda dynamic, meaning that the number of accounts can vary from 1 through 10.
Tab2 has all the data i want to search through and select using the command button in tab1. in tab2 account names is in column A and dates are in column D.
tab3 is where i want all of the selected data from tab2 using the command button from tab1 pasted.
please help me out with this
I have tried multiple if statements with no success.
here is the code i have so far

Is there a way to check if a labelbox has been updated in a manner similar to TextBox_AfterUpdate?

I am making a userform that will allow a user to click on a date in a calendar and update a labelbox on the form with the date (see image attached). I would like to write a code that will check/ensure that the "Week Start" date is always on a Monday, and if not, an error will be displayed and those labels will be cleared.
I have an "Enter" button where I've already coded what I want (see below), but would like to have the error automatically display when the user clicks the wrong date on the calendar.
If there is a way to do this in a manner similar to the TextBox AfterUpdate event, I would be greatly appreciative.
'Error message stored in Enter button if work week is selected that does
'not start on a Monday
If Not Format(datFirstDay, "w") = "2" Then
MsgBox ("Please select a work week that starts on Monday.")
lblStartDate.Caption = ""
lblStopDate.Caption = ""
LengthNo.Caption = ""
End If
Image of what the form looks like.
It looks like the user is selecting the date from the calendar and you are just using the label to display the selected date. It would be helpful to show the code that sets the value of the label. You should associate your error checking with entering the date on the calendar rather than any event related to the label. Talking about events on the label is a red herring.

Generate comboboxes depending on number inserted in first combobox

I'm doing an userform where in one of the fields (lets say its combobox1) the user is asked for the number of failures, and for each failure he has to put the type of failure, number of part and in another field the type of rework (3 fields to fill for each failure). And what I would like to know if that if it's possible to generate comboboxes depending on the number of failures made. For example: if the user puts 3 in the field of failures, 9 comboboxes should appear and so on.
I also think that maybe another way would be to have the standards 3 comboboxes and clear the fields each time the user press a button and a counter appears indicating which failure description he is filling, but I would also like to know how this could integrate into the whole userform, which already has a "submit" button.
Maybe there could be another reasoning for this, and I would greatly appreciate any help.
I don't really have much experience using dynamically created tabstrips, but they may be helpful with creating the layout you're describing. I would recommended in the base userform, include a tabstrip with a single tab and the 3 comboboxes/textboxes that are needed for a single failure. (You could keep it invisible until after "combobox1" has a value, if desired) Then use the number from the combobox to dynamically create the additional tabs on the tabstrip:
Private Sub ComboBox_Change()
'To remove previous tabs if combobox changed
For i = 1 To TabStrip1.Tabs.Count - 1
TabStrip1.Tabs.Remove(i)
Next i
'Adding additional tabs to tabstrip
For i = 1 To ComboBox.Value - 1
TabStrip1.Tabs.Add
Next i
End Sub
The tab currently selected can be identified by using the TabStrip1.Value property. I think the change event is queued by the TabStrip1.Value changing.
You will have to manually clear out any values when the tab strip changes (or fill back in values they previously filled out but want to view again).
However, since you'd be determining which tab you're on by "index" (the .value property) you could create a 2d array (redim it to correct rows/columns based off combobox1's value) and use the tab "index" to store combobox values and retrieve existing values for when the user switches back to an existing tab.
And maybe consider "locking" the combobox1 so the value can't be changed by accident. This could be accomplished by having a variable initialized to, maybe -1, which gets set to the combobox value after they've started adding infor to the incidents. Or don't remove any tabstrip tabs, only add if the number is greater than the existing count. (If you want them to put in whatever value they'd like, maybe consider using a textbox?)

Input box in MS Access 2016 Reports

I am new to MS Access. I have created a report which pulls data from excel and displays on the MS Access form output. I have added a text box for which in Properties->Control Source I added "PO#" as in fig 1.
So the user enters the value in the dialog box when he tries to open the report as below in fig 2. I need to add a default value in the dialog box in the format "LDXXXX" where XXXX is the financial year. I have the logic to generate the financial year as below:
If month <= 8 then
Current year
else
current year + 1
I don't know where to implement it. The dialog box should have the above format as default value when the user tries to open the form and it should populate in the text-box from fig 1. I know there are three events that can be accessed when we click on the text and go to "build events"-Macro, code or expression builder but how to implement this for the dialog box?
If PO# doesn't exist in the source data, it probably shouldn't be referenced as a control source. Does the user need to change the LDXXXX default, or did you implement this to ensure the value is being populated? If the latter, you could probably just use something like this as the control source of the texbox:
="LD" & IIf(Month(Date())<8,Year(Date()),Year(Date())+1)
And if the user needs to change it, keep the txtbox called 'PO#' and add code to the load event of the report.
Private Sub Report_Load()
Me.[PO#] = InputBox("Fiscal Year:", "Fiscal year", "LD" & IIf(Month(Date) < 8, Year(Date), Year(Date) + 1))
End Sub

Cognos Dynamic Filtering

I searched all over the internet but couldnt find an answer.
I want to create
1. a radio button with two options A, B (which are supposedly two columns in the database with "date" datatype) and
2. a date prompt
Now if the user selects option A with a date range(in the date prompt) the data should be filtered on A
if the user selects option B with a date range(in the date prompt) the data should be filtered on B
Your question is far from clear, but if I understand you want to use the radio button to determine which date column to use in a filter? If so, then something like this should work:
if (?RadioButtonPrompt? = 'A') then ([DateColumnA] = ?DatePrompt?)
else ([DateColumnB] = ?DatePrompt?)
If I get this straight:
1. You first want to create a Radio Button:Value Prompt with values from DB
2. Then you want to filter another Prompt based on selection of the Radio button Prompt. (You can do this by what Andrew has suggested)
To create a Radio button prompt, Drag a Value prompt > Select Radio Button Group (under Select UI) > Select Query > Select Use Value and Display Value
My guess is that you are having trouble creating Query which will just give you a single row with two date columns...
Hope that helps....

Resources