Select Between (Date) AND In TxtBox
Jul 4, 2005
Hello,
I'm trying to make a report query work but with no succes so far. Can anyone please help me?
I've got a multiselect listbox and a txtbox (txtCursisten) where the results from the multiselect listbox appear.
I want to get the results out of a table (tblAbsentie) where I can set a start and end date AND use the people selected in the txtBox. So far I've got a NOT working query, a report based on the query and a button on my form.
The VB code behind the "show report" button is this:
Private Sub cmdAbsentiePerCursistPerPeriode_Click()
On Error GoTo Err_cmdAbsentiePerCursistPerPeriode_Click
Dim db As Database
Dim Q As QueryDef
Dim sql As String
If IsNull("Me.txtCursisten") Or Me.txtCursisten = "" Then
Exit Sub
Else
Set db = currentdb()
Set Q = db.QueryDefs("qryAbsentiePerCursistPerPeriode")
Q.sql = "SELECT tblCursist.Naam, tblAbsentie.Datum, tblAbsentie.Lesuur, tblAbsentie.AantalLesuren, tblAbsentie.Deelkwalificatie, tblAbsentie.Docent, tblAbsentie.Gemotiveerd, tblAbsentie.Reden, tblAbsentie.Status, qryCountLesuren.SumOfAantalLesuren" & _
"FROM (tblCursist INNER JOIN qryCountLesuren ON tblCursist.OVnr=qryCountLesuren.OVnr) INNER JOIN tblAbsentie ON tblCursist.OVnr=tblAbsentie.OVnr" & _
"WHERE (((tblAbsentie.Datum) Between [Voer begindatum in] And [Voer einddatum in]) AND ((tblAbsentie.OVnr) In ("Me!txtCursisten"))); "
Q.Close
DoCmd.OpenReport "rptAbsentiePerCursistPerPeriode", acPreview
End If
On Error GoTo 0
Exit Sub
Exit_cmdAbsentiePerCursistPerPeriode_Click:
Exit Sub
Err_cmdAbsentiePerCursistPerPeriode_Click:
MsgBox "Selecteer klas en cursist(en)."
Resume Exit_cmdAbsentiePerCursistPerPeriode_Click
End Sub
I get a syntax error when pressing the button. Please help...
SeBasTiaan
View Replies
ADVERTISEMENT
Aug 20, 2007
Hi all,
I have a select query that pulls in two date values from a textbox on a form.
SELECT DISTINCT Table01.SRV_NAME, Table01.IMP_CUTOFF_DT
FROM Table02 INNER JOIN Table01 ON Table02.Servicer = Table01.SRV_NAME
WHERE (((Table01.IMP_CUTOFF_DT)=[forms]![frmreport].[txtsqldate].[value]))
ORDER BY Table01.SRV_NAME;
However when I run it I get the following error message:"This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may...." but when I copy and paste the value of that txbox from the form into the query it works fine.
Can anyone see where the problem lies? I can't work it out.
Thanks in advance,
Mitch....
View 5 Replies
View Related
Mar 30, 2006
I have a form that has several fields that a user will enter data. When finished, the data is inserted into a table. Works great. What I want to do now is look at one of the fields entered and if it is equal to a certain value, I want to disable one of the other text boxes (fields) on the form AND pop a screen that will allow the user to enter a list of names that will update a different table.
So, if user inputs a directory name GENERIC, the txtScriptName box needs to be disabled/greyed-out and I need a form to pop so the user can put in a list of script names. If any other directory name is entered, the txtScriptName box needs to remain editable. (For directories equal to GENERIC, there will be multiple script names instead of just one)
I've been successful at getting the form to pop if GENERIC is entered but can't figure out how to grey-out the txtScriptName field. I tried using Me.txtScriptName Locked in the Before Update of the preceding field but it didn't work - could still update the txtScriptName field.
Any other sugestions?
Thanks!
Mary
View 1 Replies
View Related
Sep 15, 2005
Hi there
Can someone give me a basic example.
I have a form that contains a textbox and a listbox. The listboxs rowsource is tblSPNZ.
The table has 2 fields 1 is and autonumber and the other is where I want the results to go.
How do I make a command button populate the table? Avoiding putting any results into the autonumber field?
Thank you for your help.
View 11 Replies
View Related
Oct 20, 2005
Is it possible to select 1 MAX date from multiple date fields for a record?
For example, on an employee record there are 10 date fields, each for a performance review date. Some employees may have date fields 1-3 with values, some with just 1, others 1-5, etc.....depending on how many performance reviews they've had.
Is there a way to pull the MAX review date for an employee, knowing that the MAX date could reside in Field 1 for a certain employee, and could be from Field 7 for another?
I appreciate the help guys!
View 1 Replies
View Related
Dec 14, 2006
I have a form, on the form a textbox. Through the expression builder I have assigned one value to the control source of that textbox from a query. The query holds three values, all three of which I would like to use in a separate textbox. When I open the form the textbox just displays #Name. I'm guessing since nothing is happening because the query isn't run by command yet. I've used code like this:
Private Sub AppointmentID_Click()
Forms![ClientsMain]![TechViewSummarySubForm].Form.Requery
Forms![ClientsMain]![TechViewSummarySubForm].Form.Refresh
End Sub
to get a query to open, run etc. But that one is located in a subform which has the query as a control source. How does that work in the case I have now? Can I use the DoCmd function to run the query and get a value from it for the specific textbox? Or can't I use a (segment of a) query as the controlsource of a textbox at all?
I'm asking this since now I calculate and store certain totals by use of a textbox with =Sum() as control source in the footer of a form, which values I then assign to some fields in a table.
But I would also like to learn the right way, using queries, maybe for a later version of my DB when my skills have improved. I've been struggling with this now for a bit, but without succes. So that's why I wonder if I can assign a query or more specific one value of a couple of values in a query to a textbox in a form which has a totally different control source itself.
View 3 Replies
View Related
Jun 27, 2005
Here's a bit of a pickle I've been trying to wrap my noodle around.
Anyone have an idea what route to pursue (unbound form, or afterupdate, etc?) to force a validation rule on the number of characters in a text box based on the value of combobox in the same form.
Example:
If cboBox1 = 840, then len(txtBox2) = 6
But if cboBox1 = 820, then len(txtBox2) = 3
And so forth?
Thanks,
~Chad
View 5 Replies
View Related
Oct 3, 2006
friends, a small question.
I have placed a txtbox on my form and via a cmdbutton a can copy data to another text box. Is there a way I can replace data? Will appreciate any help.
View 4 Replies
View Related
Jun 7, 2014
I have a form that has a combobox and a field text. If i select any value in combobox i want to update the txtBox but not with the ID of the selection. I need to get the description of the combobox selection which is essentially the Column 2.
View 3 Replies
View Related
May 18, 2007
Hello,
In a form I have "txtBoxA". I would like store the number of records from table "A" based on a specific field into "txtBoxA".
Ex:
Table 'A' fields: QuoteID, Date, GenerateOrder
What would be the exact syntax for this??
The following code is not working
Me.txtBoxA.Value = DoCmd.RunSQL ("SELECT COUNT(GenerateOrder) FROM A")
Thanks
View 2 Replies
View Related
Jun 17, 2005
Having had a pretty good look around, I think I must have missed something...
I just want to try and make a Forms single Address textbox = multiple table fields values:
Add1
Add2
Add3
PostCode
Cheers,
Pailin
View 2 Replies
View Related
Mar 12, 2008
It's an unusual request, I know, but it's necessary for my purpose.
I have a form, frmMain that I use to update a number of tables. On it is a number of combo boxs, comProduct, comBrand, comSize, comPrice and comQuantity. comProduct opens a new form, frmNew if the users input is not already in the table. On frmNew there are again combo boxes comProduct, comBrand and comSize. This form adds the record to the table.
So, if I input a new value - not already in the database - for product in the comProduct combo box, the form frmNew appears and I can proceed to define the product, brand and size of the new record. The form then closes and reopens frmMain and tabs across to comQuantity (skipping the fields I've already defined in frmNew).
Now if you can wrap your head around that, here is the problem: Because I've already entered the values for product, brand and size in frmNew, I want them to automatically appear in the appropriate combo boxs on the frmMain form. I've been using the following code (executed from frmNew, so Me = frmNew):
Code:[Forms]![frmMain].[comProduct] = Me.comProduct[Forms]![frmMain].[comSize] = Me.comSize[Forms]![frmMain].[comBrand] = Me.comBrand
It works, but I've since discovered it creates a new record in the table so I end up with two duplicate records (one when I submit frmNew and another when the values are automatically input into frmMain.)
Now, my question: How can I display these values in frmMain without having them create the second record? I was thinking of using a SELECT query somehow, but I don't know where to begin. I also considered using labels instead of comb boxes, but I'll need to be able to edit them if the record already exists.
View 3 Replies
View Related
Aug 19, 2015
I have a table tblDateGroups, with two field, [Group] (like This Week, Next Week, Last Month, etc) and [Code] that holds the code for criteria for each group in a query. I know the code is fine (like next week = Between Date()-Weekday(Date())+8 and Date()-Weekday(Date())+14 ) because I tested before putting in the table.
On my form I have a combo box that list all the [Group] and i hidden textbox that looks up the code based on the cbx after update...all that is good.
However, when i try to requery the report the criteria is not working. I am simply using the date criteria to read the hidden text box with the code string.
Forms!frmMainHome!subaWelcome.Form!txtCodeForQuery .
the error code is "This expression is typed incorrectly, or it is too complex to be evaluated. For example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expression to variables."
View 2 Replies
View Related
Feb 22, 2006
Hi.
I have
Form with 3 list boxes.
1st LB populates 2nd etc.
The 3rd LB value chooses a field.
The Fieldname Table has field "Field Type"
I want to change the Text box next to the List box to this entry in the Db.
Ie. If I choose a field in the LB, say "Done?", then to update that field it needs to offer me a "yes/no" field type
Therefore it changes the TextBox to a Checkbox (or combo with Yes and No as options)
Any ideas?
View 2 Replies
View Related
Aug 2, 2007
hi Guys
I would like to write an expression (i presume) to auto fill a text box based on the selection made from a combobox...can anyone help or point me to a tutorial that deals with this??
Many Thanks,
RF
View 10 Replies
View Related
Feb 28, 2006
I have set up a query that includes:
An assignment start date
An assignment end date
and in addition a column has been set up to show me a Start Date where Assignment End Dates are Null i.e all live assignments.
When I enter a date only results for that particular date are visible.
Can anyone suggest how i can expand this to include all live assignments?
Thanks
View 1 Replies
View Related
Nov 15, 2005
I have a table that shows me 3 fields:
PROCESS
EFFECTIVE_
OPERATION_
My issue is each process and operation may be there multiple times due to multiple Effective dates. I only need to see each Process and Operation one time based on the latest Effective date. Below is what I have NOW:
PROCESS EFFECTIVE_ OPERATION_
1/010/1-8TCOWLFEEDER 2005-11-01 10
1/010/1-8TCOWLFEEDER 2005-11-01 20
1/010/1-8TCOWLFEEDER 2005-11-01 30
1/010/1-8TCOWLFEEDER 2005-11-01 40
1/010/1-8TCOWLFEEDER 2005-11-03 10
1/010/1-8TCOWLFEEDER 2005-11-03 20
1/010/1-8TCOWLFEEDER 2005-11-03 30
1/010/1-8TCOWLFEEDER 2005-11-03 40
1/010/1-8TCOWLFEEDER 2005-11-09 10
1/010/1-8TCOWLFEEDER 2005-11-09 20
1/010/1-8TCOWLFEEDER 2005-11-09 30
1/010/1-8TCOWLFEEDER 2005-11-09 40
This is what I need:
PROCESS EFFECTIVE_ OPERATION_
1/010/1-8TCOWLFEEDER 2005-11-09 10
1/010/1-8TCOWLFEEDER 2005-11-09 20
1/010/1-8TCOWLFEEDER 2005-11-09 30
1/010/1-8TCOWLFEEDER 2005-11-09 40
Out of the records above I would only want to see the records with the 2005-11-09 date. The dates can vary based on processes so I really need something that selects the the latest date for each Process and Operation. I would like to do this in a query or multiple queries.
Thanks for any help.
View 2 Replies
View Related
Dec 4, 2005
sql = sql & " WHERE (((tblAccountBalance.DateLastPayment) < #" & reminderdate & "#))"
Im trying to select all the entrys in a table where the date of the last payment is before a variable 'reminderdate' this works fine if both dates are in the same month ie, DateLastPayment = 26/11/05 and reminder date = 30/11/05, but if the DatelastPayment is 26/11/05 and the reminder date is 01/12/05 then nothing is found.
What am I doing wrong?
View 7 Replies
View Related
Jan 17, 2006
I have attached a small sample DB.
What I'm trying to do is to find the most recent payment date for each customer before 01/13/2006.
These are the results I'm looking for.
Customer 123456 should return the date 12/01/2005
Customer 12345 should returtn the date 01/01/2006
Can someone show me how to write a query to accomplish this?
Thanks
View 1 Replies
View Related
Aug 28, 2007
hi, how do I select my data where the date is beyond the date range specified? For instance, I wan to select all the rows except the rows that are between 3/22/2005 to 10/17/2005. Is it possible to select the query? I tried the condition 'where date < #3/22/2005# and date > #10/17/2005#', but it return no rows at all. Does anyone knows how to do smth lidat??
View 14 Replies
View Related
Aug 25, 2006
hey, little prob for improving my database..
In a box on the form i have the date automatically entered. however it is also possible for people to change the date for say the day before or the day after.
SO what i really want is for the date to still autoset (most of the entries will be for the current day) but i also want two little arrows on the box (like standard scroll bar style) to give me whatever date in the future, or past, that i require.
at the moment this can be done manually, but i want to make it as simple as possible so no gets to befuddled!!!
cheers for the help (if anyone can)
Myle
View 2 Replies
View Related
Sep 17, 2013
I know you could select a date by using the show date picker as for dates in property and a calendar pops up. But can you select a time too, separately or together with the date? Together as in one field where you choose a date with the calendar pop up and then also choose a time for that date.The result resides in one field. I doubt this is possible.
If not possible, then have two fields, one is to choose a date with the calendar picker, another with a time picker, both date and time now will be in separate fields, can this be done?
View 2 Replies
View Related
Jul 21, 2005
I have a simple table in Access 2003:
Case# (numeric)
CaseOpen (Date)
CaseClose (Date)
Item# (numeric)
ItemOpen (Date)
ItemClose (Date)
Some of the date fields may be null; If null then that date may NOT be selected
I am trying to write a query that returns:
Case#
Item#
Only the most recent date in any of the four date fields
The heading that matches the selected date field
ie:
Case# = 251
Item# = 4756
Most Recent Date = 7/8/2005
Matching Heading = "ItemOpen"
I have been searching and reading for two days-
Help, please?
TIA
View 1 Replies
View Related
Dec 12, 2007
Hi all, I need to extract in a query a recent range of records, these records should be all before a certain date and all the following future records example:
if today date is 12/12/2007 I need to extract all records that are dated from the 1st of november and all the records that come after the 12/12/2007.
In the criteria I have set "Date()" what else should I be adding to get the range mentioned above?
Thanks
View 5 Replies
View Related
Apr 3, 2006
OK I have done a select case as follows
Private Sub Form_Current()
Select Case DatePart("w", Tape_Date)
Case 1, 3, 5
Clearly this runs/works on a Sunday, Tuesday and Thursday.
I have tried to adjust this to work on a specific date but I'm struggling.
Would I use 'datePart' or just 'Date' and what format in the case would I use.
Thanks in advance
View 6 Replies
View Related
May 19, 2005
I have a table that stores price records with a field for the effective date but there is no field for the inactive date. How can I write a query to return the price for a date that falls between recorded effective dates?
Example: A record exists for 12/03/2005 and the next is 01/04/2005. How can I find the effective price on 18/04/2005?
Thanks
View 2 Replies
View Related