VBA AddDate based on userform entry - vba

I'm trying to manipulate a date with a userform. The userform has a text box where you enter a date, then I have a dropdown where you select a number.
The number you select determines how many months are added to the date. If you put 1/1/2017 and select 3, then you should get 4/1/2017. The issue is that when I use the AddDate function, it will not let me use this:
AddDate("m", Userform1.ComboBox1.Value, Userform1.TextBox1.Value)
It will not let me pull values from the userform. Any suggestions are greatly appreciated.

Try this:
With UserForm1
.TextBox1.Value = DateAdd("m", .ComboBox1.Value, CDate(.TextBox1.Value))
End With

Related

How to use VBA to change a date in SQL query in excel

I need help if it is possible where I can upload SQL query in excel via Get Data>From Database>From SQL Server Database, and be able to change the date in this uploaded SQL query.
My hope is to use three cells within tab where i enter a date, and either use a vba or SQL looks cell value automatically and provide results when i refresh SQL.
Right now i have these sets of dates.
set #eomdate = '2022-10-31'
set #startdate = '2016-01-01'
set #enddate = '2022-10-31'
I want to use cells in excel that lookup date entered in cell A1, B1, and C1. My goal is to change the dates to get results based on dates entered.
set #eomdate = Sheet1A1
set #startdate = Sheet1B1
set #enddate = Sheet1C1
is there a way to use a VBA code that will change the dates based on cells mentioned above? I am researching but have been unlucky.
Private Sub CommandButton1_Click()
Dim ws As Worksheet
Set ws = Worksheets("Query1")
`ActiveWorkbook.RefreshAll`
End Sub
Any help is greatly appreciated.
Thank you,
Kosta
This is the first time I am trying to do this but I am hoping that when I enter a date in cell A1, and i run a vba CommandButton1, the SQL that was uploaded in excel, will change the date prior running the SQL query.

MS Access date range search leaving out records that should be within date range

I have a lookup form with text boxes for commodity, start date and end date
The commodity section has criteria here
`[Forms]![Traceability_F]![Material]`
also an OR criteria for if the text box is blank
`[Forms]![Traceability_F]![Material] is null`
The date range criteria is
`Between [Forms]![Traceability_F]![StartDate] And [Forms]![Traceability_F]![EndDate]`
also an OR criteria for if date range is blank
`([Inventory Usage].[Date Used]) Between [Forms]![Traceability_F]![StartDate] And [Forms]![Traceability_F]![EndDate]`
When the search button is clicked and nothing is entered into the text boxes the query opens with all records. This is what I wanted
When the search button is clicked and nothing is in the commodity text box the query shows up blank. Not what I wanted. I was trying to get it to show all records for that date range
When commodity and date range is inputted the query shows the commodity but the dates of the commodity are sometimes not in the date range or the query omits records that should be within the date range. For example the table that is being pulled from has records from 9/26/22-10/14/22 when those dates are inputted a few records in that range do not show up. Records from 10/11,10/13 do not show up.
Clearly something is wrong with the date range function of my form. I would like to be able to enter a date range and see all records entered in that date range. Also when a commodity is entered along with the date range I want to be able to see all records of that specific commodity in that date range.
The commodity section has criteria shown in image 3. Having trouble entering it in this section.
Any help would be greatly appreciated. I have attached an image of my form and can add in the SQL information but I am new to SQL.
Thanks,
Kyle
[search form][1]
[SQL for Query][2]
[Query Design][3]
[1]: https://i.stack.imgur.com/4WdsY.png
[2]: https://i.stack.imgur.com/a82rx.png
[3]: https://i.stack.imgur.com/P6Bkg.png
Try to declare the form fields as DateTime in the query SQL:
Parameters
[Forms]![Traceability_F]![StartDate] DateTime,
[Forms]![Traceability_F]![EndDate] DateTime;
Select ... <snip>

How to select a date from calendar in selenium webdriver

I am trying to automate price line website and trying to select the date range. But unable to do it.
There are two way i can think of to select date from calendar.
First way and easy way:
If date field is a textbox or if you can set the date using selenium sendKeys , you can go for sendkeys itself to select the date. Just make sure the format of input.
Second way:
You have the build the logic to select the date, i can suggest one way to select date here,
First format the input date(your input) as day , month and year.
Select the year first(it's depends on the application like selecting from dropdown or click left and right arrow , etc...).
Go for the month next and then day.
you can still put some condition while selecting the date for example, checking date is not disable before selecting it.

Qlikview how to get all excluded values on qlikview

I have two columns on Qlikview table: date and full name.
All people work on some dates.
If I choose a date, it shows me a list of people who work on that date.
I need to make a table of all the people that do not work on that date.
I have tried to make a page trigger to select unchecked but it doesn't help me.
Select the date you want -> Right click on the date's list box and do 'select excluded'
Try to use element function E() which represent the excluded set.
sum({$<Dim1 = E({$})>} Expression1)
In your case Dim1 would be the Date dimension.
//Micke
Click on the date you want.
Right click on it.
Select Excluded.

How to display a next day date?

Using VB.NET
Using DatagridView, In a Datagrid View values are displaying like this
ID Date
001 23/02/2009
001 24/02/2009
001 25/02/2009
I want to display a date in a textbox after 25/02/2009
I Used a sql query for getting a next date
Select CONVERT(CHAR(10), DATEADD(dd, 1, MAX(SDate)), 103) AS SDate from tb_Sched_Add
the above query is displaying a next date 26/02/2009 in the textbox, but it is taking a some second to display. There is any way in program itself getting a last value of the row (date) in datagridview and display the next date.
Need vb.net code help
If you have a date in your VB.NET code you can use the DateTime.AddDays method:
Dim latestDate As DateTime = SomeMethodThatGetsLastDate()
Dim nextDate As DateTime = latestDate.AddDays(1)
Perhaps you have populated a list with the existing items, so that you can obtain the latest date from that data?
THis option is nice, tho then if you are to iterate with a button click, you are likely to land into issues of not going more than 2 days in go. So a counter has to be in place to increment the value in AddDays(1) so replace "1" with counter++