Symbol required to enter date in text strings - ms-access

I am working on a homework assignment for school, and I have come across one particular question which has me a little stumped. The question is, 11. What symbol does Access SQL require to enter dates in text strings? I have found the use of ''(single quotes), " " (double quotes), and #(pound sign), but I have not been able to find a definitive answer to this particular questions. Which would be the correct answer?

Since this is homework, I'll show you how to find the answer you need.
Open the Immediate window (Ctrl+g) and run both of these statements (pressing Enter after each):
Debug.Print TypeName("5/2/2013")
Debug.Print TypeName(#5/2/2013#)
However it's safer to use yyyy/m/d format with literal date values to avoid locale issues ... ie does 5/2/2013 represent May 2nd or Feb 5th?
Debug.Print TypeName("2013/5/2")
Debug.Print TypeName(#2013/5/2#)

Related

Using backspace - CHR(8) - in Access Query

I have a parts management MS Access database. One of the fields is rarely used - it stores whether a part in inventory is actually rare variant of a more common part. Normally the field is used as a suffix to the primary part number and the database generates that in reports while storing the parent part in the database. (One primary database which controls part numbers does not contain any information on the variants, but it's important to store because the storefront database does.)
I've found in some cases the variant is not simply a suffix. In some cases the correct variant part number eliminates a character from the parent part. For example part "3069b" has a variant "3069bpb198". But I found part "30361c" has a variant "30361pb016" which eliminated the "c".
My preferred solution is to encode a backspace character into the field for those variants which require it. Then when i concatenate the parent part number with the variant number, "30361c" & "\bpb016" becomes "30361pb016". However the output I get in my Access query is "30361c□pb016".
The concatenation formulas in the query I've tried are:
PartNum: [pl].[PartID] & [variant] 'returns "30361c\bpb016"
PartNum: Replace([pl].[PartID] & [variant],"\b",Chr(8))
Is what I'm trying to do possible? And if so what am I doing wrong?
I'd really like to avoid having to change the database so the variant contains the full part number instead of a suffix.
How about:
PartNum: left([pl].[PartID],len([pl].[PartID])-1) & [variant]
Well, you might be able to concatenate the backspace, but how and if that will effect the display of the data is a MASSIVE different issue. The use of ctrl-H goes back to the days of green screens, and even the tele-type age. In other words you want a way to optional remove a character, and using ctrl-H with modern GUI and systems that really don't represent a ASCII character steams means that the question is not about how to make ctrl-H work to chop a char, but how can one chop off a character based on some kind of information.
In other words ctr-H is a crazy approach unless you using a ASCII green screen, or say a printer.
I also would not introduce a non printable character into that data, since you can't type that information into a field, and worse yet you thus can't search, sort and deal with that column as data.
It gets even worse. Your business rule is that "some" data in one column is to effect the display of another column!!!! This breaks the relational data model so bad, it is not even funny.
What you need is to add a bit column (true/false). In fact, really what needs to occur is the selection of the first column needs to take into account the 2nd column, and a DIFFERNT choice should have been made here.
Now this trick/idea might have worked 25 years ago when most computers were ASCII, working with green screens, and output to a screen/terminal or even for crazy sakes a teletype machine? Well, then ctrl-H would work.
Modern systems are displaying data in a graphical format, and the data is not really ASCII anymore - but is saved in uni-code. (which allows display in just about any language or region).
Now, assuming that the people who suffered some serious brain damage to consider polluting the data this way?
Well, you could use this function:
Public Function vScrub(ByVal s As Variant) As String
Dim c As Integer
If IsNull(s) Then
vScrub = ""
Exit Function
Else
c = InStr(s, Chr(8))
Do While c <> 0
s = Left(s, c - 2) & Mid(s, c + 1)
c = InStr(s, Chr(8))
Loop
End If
vScrub = s
End Function
So, place the above in a standard code module (not a class module, nor a forms module).
Once done, then any form, any report, and yes even any query can simply wrap the string expression with above
eg:
vScrub([Col1] & [col2])
Edit:
Modify routine to work for multiple chr(8) in the string.

MS Access, in trigger, SetField to format(Now(),"Short Date") broken

MS Office 365 ProPlus, Access 2007 - 2016
I recently noticed that the definitions of set field commands in triggers I've written have changed without my doing. I recently split the DB (frontend/backend), but am not sure if this is what caused this. Here's what happened...
Before:
SetField
Name last_mod_date
Value =Format(Now(),"Short Date")
Now...
SetField
Name last_mod_date
Value =Format(Now()|"Short Date")
(That's not a typo, the "|" replaced the ",")
If all I do is click the "Before Change" (under "Table" tab, to see my triggers), and then "Save", I get a pop-up...
The 'SetField' macro action has an invalid value for the 'Value' argument."
(and it highlights the "Value" line) in the SetField block.
IOW, I made no changes, but it no longer likes what's there.
And I can understand that. Where did the "|" come from? I didn't put it there. Anyway, I replace it with a "," (common sense), click "Save" and get the same pop-up.
It would be interesting to know why my "," got replaced with "|". But I'd much rather learn how to just fix this. The Format(Now(),"Short Date") doesn't seem to work either.
Any ideas?
You're gonna love this.
I figured it out. In order to be able to import a csv with a delimiter other than ",", I set the list delimiter (using... control panel -> Regional Language Settings -> List Delimiter) to (you guessed it) "|". I just set it back and the problem is gone.
Why on Earth would the default list separator setting affect the content of a trigger definition deep inside an Access trigger is beyond me. But there it is.
You should never attempt to store date/time as text - which is what Format returns. So:
SetField
Name last_mod_date
Value = Now()
To store the date only:
SetField
Name last_mod_date
Value = Date()

Crystal Reports & Access 2013 - Continuous Form?

Original Question
In Crystal Reports 2011, how do I show all values from a certain Field?
My formula that pulls the data from an Access DB is simply:
{tblQuoteFormSub_Windows.fQty} & " - " &
{tblQuoteFormSub_Windows.fWindowSizeW} &
" x " & {tblQuoteFormSub_Windows.fWindowSizeH}
If I right click on the field in Design or Preview Mode, I can select "Browse Field Data, and see all the values, but I cannot figure out how to print all of them.
EDIT:
I used a sub report (I am still learning, and didn't know they existed in CR until today). Now I can view the records I need based on the fJobID Field.
However...
I need a way to select which group to print... Preferably by using a control in Access to select a Job #. Should I post that as a new question?
The subreport is a good idea. I was thinking of suggesting that, but I wasn't sure if it would have met your needs. I haven't tried Access 2013 yet, and it's been awhile since I've even seen CR. But as for your other question, I can give you one suggestion that I used with previous versions.
In your Access query, add a parameter to your query, i.e. Select * from mytable where job='[Enter Job Num]'. Then when you preview your CR, that parameter should filter through so that it will ask you for the job number when you preview it.
Give it a try and let me know if it worked.

Display all SSRS report field values without line breaks

I have an SSRS report with a dataset that I cannot modify. I can only change the report's format.
I am trying to figure out how to have one of the reports fields display its many values inline in a list or csv fashion. Right now it prints a value and does a line break, then the next value and another line break, and so on... I would like my values to print without the line breaks.
I've tried using the Replace function in an expression (replace vbcrlf with ", ") with no success...
You're not quite providing enough information to reliably answer the question. Most likely, your question is a duplicate of this question, and my answer there will answer your question as well. The basics are:
Create a multi-value parameter #MyParameter
Set the default values for the parameter to be retrieved from your dataset
In your textbox use the expression =Join(Parameters!MyParameter.Value, ", ")
Same disclaimer holds here as well: if there are a lot of values this solution may not work very well.
It sounds like you just want an expression to remove the line feed characters in your source data so that it prints on one line. You'll probably need a bit of trial and error to work our what the characters actually are but you probably want to start with replacing:
vbCrLf
vbLf
vbCr
More on replacing line breaks in this question
You could create a Code function in the report to do the replacing, similar to the answer in this question.

Returning specific field from a matching record

I'm still a newbie at Access 2007, but I feel I am missing a understanding of a concept, when it comes to using user input from an unbound text box.
I'm trying to have the user input the record number (i.e. A12) and return another field in the matching record (such as the record status like "Opened")
I'm fiddling with DLookup to see if it will work through that method but no luck yet.
I may look into SELECT - SQL, but I haven't used that function yet and not sure if that will give me the result I'm looking for.
If this is something elementary to access programming (or databases in general), please let me know where I can read up on this.
I am currently using the MSDN website, but examples go much further to play with.
Edit:
My DLookup so far, which happens after update from user on Text12
Me.Text14.Value = DLookup("[RecordStatus]", "Orders", Text12.Value)
Thanks
Look closer at the third option (Criteria) in your DLookup() expression. You gave it only Text12.Value, which I assume is a string value like "A12".
The Criteria parameter should be like a WHERE clause in a query, without the word WHERE. IOW, some field's value = "A12". If that field is named "record_id", try this:
DLookup("RecordStatus", "Orders", "record_id = '" & Me.Text12 & "'")