Query Question (detailed fairly new user)

Brott

Board Regular
Joined
Dec 12, 2002
Messages
110
I hope I get this across the way I want to. If you provide any assistance please make it very detailed. Meaning please don't assume I may know what your talking about.
I will describe this using four columns. Once I learn how to do this I will be able to apply this all over the place. :)
The table will consite of "Date", "MegaWatt", "LowTemp", "HighTemp".
What I am looking for is to be able to have a form where I can enter a date range (beginning & ending date) and then see all data for that date.
On that same note I need to be able to query based either a Megawatt (greater than, less than or between two values) and the same for Temps.
The purpose for this is I have taken years (7 years hourly data) and put them into a access dba. I am tring to help the operators query previous dates where either the temps/MegaWatt were within a certain range that way they can make decisions without having to flip through multi 5" three ring binders to find another day like the current day.
I don't think that is that difficult. It will probable be more difficult to explain it to me. :ROFLMAO:
I am somewhat familiar with VBA and SQL statements. I just don't know the syntax's.
If you feel brave to take this on, I thank you!!
:rolleyes:
 

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
For the first part create a form based on your table.

Add each field required.

Then add a command button and two unbound textboxs (don't put anything in ControlSource)

Name the textboxs txtStart and txtEnd and set their input masl property to 99/99/0000;0;_ and format to short date.

Add this piece of code for the command button:

Code:
Private Sub Command1_Click()
Dim strFilter As String

    If Not (Me.FilterOn) Then

' change {Date] to whatever your field name is

        strFilter = "[Date] Between #" & Me.txtStart & "# And #" & Me.txtEnd & "#"

        Me.Filter = strFilter
        Me.FilterOn = True
    Else
        Me.FilterOn = False
    End If
End Sub

This should get you started.

It doesn't check for valid user input.

You'll be able to do similar for the other fields.
 
Upvote 0
Here is my two cents, I like the Active X control called Calendar. I have used it to do just as you ask. It allows the user to select beginning date and ending date and then run the query based off of this. You may want to take a look at it.
 
Upvote 0

Forum statistics

Threads
1,221,704
Messages
6,161,390
Members
451,701
Latest member
ckrings

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top