Status bar to display a cell value? - ms-access

I use the status bar in nearly all my macros . If implemented correctly , allows you to see where your code is at.
E.g
SysCmd(4, "Sorting...")
SysCmd(5)’Set status bar back to normal
Question - How do I get the status bar to display a cell value?
E.g
SysCmd(4, "Sorting...") & xl.("Sheet1").Range("A1")
Above doesn’t work, but is there a way of doing this, in Access VBA ?

When you use 4 (acSysCmdSetStatus) as the first argument to SysCmd, you can include only one additional argument ... so two arguments total, not three.
But you can combine your proposed second and third arguments into one string, and SysCmd will cooperate ...
SysCmd acSysCmdSetStatus, "Sorting... " & xl.("Sheet1").Range("A1")
Note I assumed xl in your cell reference, xl.("Sheet1").Range("A1"), is an Excel workbook object. Since it turns out xl is an application object, Sobigen's suggestion, xl.activeworkbook.sheets("Sheet1").Range("A1"), makes sense to me.
But whatever the correct cell reference is, take that and concatenate it with whatever else you want to appear in the status text ... and use that entire string as the second argument to SysCmd

Related

Expression in Textbox not passing value to the table

Obviously I am not an Access expert or I would not be asking this question. I created a small database with several tables. On a form, there are several combo boxes for the user to choose different combinations of medium, paper, sizes, etc. I have already created an expression that returns the correct value I need, but I cannot figure out how to get this value into the correct field on the table to store with the record the form is creating. Below are screen shots of the form and a couple of the tables. I have also included the expression I am using. I need the value that the expression returns to go into tbl1Artwork and populate the ArtWorkSKU field.
Expression:
=Left([PieceName],4) & [cbxArtist].Column & [cbxMedium].Column & [cbxPaperType].Column & [cbxPrintType].Column & [cbxSize].Column
The ArtWorkSKU text box is unbound as I had to type the expression in there. I am not sure if this is the correct way to accomplish the goal. In the tables below, except for the PK, all fields are Short Text.
All guidance is greatly appreciated.
Saving calculated data is usually not necessary and can be risky. Saved value can become 'out of sync' with raw data. Value can be calculated when needed.
Saving calculated data requires code (macro or VBA).
Can be as simple as Me!fieldname = Me.controlname.
Real trick is figuring out what event(s) to put code into. In your case, most likely form BeforeUpdate.
Advise not to use spaces nor punctuation/special characters (underscore only exception) in naming convention. Better would be ArtworkSKU or ArtworkSKUnum or Artwork_SKU_Num.
Create the following function in VBA:
Function UpdateSKU()
Me.ArtWorkSKU = Left(Me.[PieceName],4) & Me.[cbxArtist].Column(3) & _
Me.[cbxMedium].Column(2) & Me.[cbxPaperType].Column(2) & _
Me.[cbxPrintType].Column(2) & Me.[cbxSize].Column(2)
End Function
Then, on the form, update the After Update event property (not vba) of each "feeder" control to:
After Update: =UpdateSKU()

How to input two functions into 1 cell?

Is it possible to have 2 custom functions in one cell?
I currently have one function and another function connected through a & symbol. But what ends up happening is that both of them run at the same time, thus producing two results in one cell. I want it to be so that when one is true the other one won't be seen and only the result of one will be showing.
Any help?
Just use IF
=IF(fn1(B1), fn1(B1), "") & IF(fn2(B1), fn2(B1), "")
if fn1() returns false the first part will be an empty string "" otherwise it will be the result. Same for the second part.
IF documentation

Addition formula to increment each cell in range by $2

I have a spreadsheet with roughly 750 part numbers and costs on it. I need to add $2 to each cost (not total the whole column). The range would be something like D1:D628 and I've tried using =SUM but either I'm doing it wrong or it isn't possible.
I initially tried =SUM(D1:D628+2) and got a circular reference warning, I've tried variations of the formula and keep getting errors even after removing the circular reference. I also tried the following VBA module insert:
Sub Add2Formula()
' Add 2
For Each c In Selection
c.Activate
ActiveCell.FormulaR1C1 = "= " & ActiveCell.Formula & "+2"
Next c
End Sub
If you just want to add 2 to a range of numbers (not formulas) then
enter the number 2 in a blank cell somewhere
copy it
Select the cells you want to add 2 to, and then select paste special, choose ADD as the operation option.
The following formula should work
{=SUM(D1:D628+2)}
Leave out the curly braces but press CTRL+SHIFT+ENTER to enter the function (rather than just ENTER)
EDIT: explanation
by pressing CTRL+SHIFT+ENTER excel treats the formula as an array, and loops through each cell individually adding 2 and then summing

SSRS 2005 Report Preview: Object reference not set to an instance of an object

This is my error and I have read through many of the fixes for this on the site, though none of them seem to address what I am seeing.
I can run my report just fine and the data displays correctly.
My issue is that I am building a hyperlink off of the columns.
I know its one column that is the issue as when I eliminate it from my hyperlink it forms just fine.
My Hyperlink is this:
=Fields!websiteURL.Value & "customer.asp?customerId=" & Iif(Fields!isGuidYN.Value="Y","{","") & Fields!customerId.Value.ToString() & Iif(Fields!isGuidYN.Value="Y","}","") & "&loanId=" & Iif(Fields!isGuidYN.Value="Y","{","") & Fields!loanId.Value.ToString() & Iif(Fields!isGuidYN.Value="Y","}","")
if I eliminate the Fields!loanId.Value.Tostring() the link builds without error (but is no longer useful). Have also tried Fields!loanId.Value.Tostring and Fields!loanId.Value (as this is a string value from the db)
I have tried to hardcode the value from the SQL draw that is that field. 'Test' as loanId and the string comes out fine.
The text box that displays the value on the report is fine and the text is normal on the report. So the data is there, its in the field that displays it, but the hyperlink is not built correctly.
Its just building the Hyperlink gives that error.
The entirety of the error is:
[rsRuntimeErrorInExpression] The Hyperlink expression for the textbox ‘textbox10.ActionInfo.Action’ contains an error: Object reference not set to an instance of an object.
This is not a trickle down error as it is the last one and when I remove the value from the hyperlink the report comes out with 0 errors and 0 warnings.
Any insights would be phenomenal.
Thanks
T
Can you try this expression:
=Fields!websiteURL.Value.ToString() & "customer.asp?customerId=" & Iif(Fields!isGuidYN.Value.ToString()="Y","{","") & Fields!customerId.Value.ToString() & Iif(Fields!isGuidYN.Value.ToString()="Y","}","") & "&loanId=" & Iif(Fields!isGuidYN.Value.ToString()="Y","{","") & Fields!loanId.Value.ToString() & Iif(Fields!isGuidYN.Value.ToString()="Y","}","")
and also make sure that you are using all fields names as it is appearing in dataset. Because in ssrs, names are case sensitive.
OK this wasn't what I was looking for but the report came through when I did something rather foolish..right in that category of "That can't possibly help but let's try it anyways..."
So originally I had a select statement like..
SELECT ...,
loanId,
...
FROM ...
When I ran this I got the loanId but it wouldn't parse the value to a string in order to make it a URL. The value appears in the field on the report, but it doesn't bring it across to the URL.
I even did this:
SELECT ...
'Test' as loanId,
...
FROM ...
That gave me the URL and the report liked it, but of course its not a valid URL for my purposes.
So I wound up doing this and the report likes it, builds the URL and I have no idea why
SELECT ...
loanId,
loanId as loanId2,
...
From ...
Now the report likes both the loanId field and the loanId2 field parses to the URL correctly.
Sure its ugly. But I spent way too much time trying to figure it out

Microsoft Access 2007, Macro issue, form and database with phone numbers

I'm trying to write a little form which accepts some user input, and on the basis of some logic displays one of two possible other forms. Everything is working fine if I use simple, unformatted data, but I hit a problem if the data in question has an input mask of a phone number. Presumably there's a trick here to ignore formatting characters or some such?
The actual logic looks for records in a particular table whose values match the data entered. Something like this cut down example:
A form, which is not associated with any specific table, containing one data entry field, called FormFieldY, and a button whose onClick invokes a Macro whose condition looks for matching data in a table.
DCount("*","TableX","[MyColumn] = [FormFieldY] " ) > 0
Now, if I MyColumn in the table has simple text or numeric values this works just fine. However if I apply a Telephone number input mask to that column, I never get a match. I have tried applying an input mask to my form field, or typing literally into the form field a fully formatted number
(1234) 56789012
neither gives a match. However if instead I hack the macro and enter a suitable hard-coded formatted valueL
DCount("*","TableX","[MyColumn] = '(1234) 56789012'" ) > 0
It works just fine.
I think you may have two issues going on. The first is that your format property displays the parentheses when a user types in a phone number, but those parentheses are not included in the value of FormFieldY --- they are display-only.
You can verify the value of FormFieldY by assigning this code to its After Update event:
Private Sub FormFieldY_AfterUpdate()
MsgBox Me.FormFieldY
End Sub
If you want the parentheses stored as part of FormFieldY's value, perhaps you would get more joy by using an input mask rather than a format. With Access 2003, I used this as my text box control's input mask:
!\(999") "000\-0000;0;_
But it's probably easiest to use the Input Mask Wizard (click the button with 3 dots, which is just to the right of the Input Mask line on your control's property sheet). Choose phone number on the first wizard page. On the Wizard page which asks "How do you want to store the data?", select the "With the symbols in the mask" radio button.
Comment from djna: That was the solution, the expression change below seems not to be needed
The other issue is your DCount expression:
DCount("*","TableX","[MyColumn] = [FormFieldY] " ) > 0
I think you should use the value of FormFieldY rather than the name of the control. That may not be clear, so here's what I mean:
DCount("*","TableX","[MyColumn] = '" & Me.FormFieldY & "'" ) > 0