Running Microsoft Office 365, Windows 7 Enterprise.
When working with a test table in datasheet view, a data macro will not detect when the “Status” field changes. The data macro works properly as long as the ‘Allow Multiple Values’ attribute is set to NO. But the function “Updated” does not detect a field value change when the ‘Allow Multiple Values’ attribute is set to YES.
Tbl_TEST:After Update – data macro
If Updated(“Status”) Then
SetLocalVar
Name: RecordID
Expression: =[tbl_TEST].[RecordID]
Else
StopMacro
End If
Look Up A Record In tbl_TEST
Where Condition: =[tbl_Test].[RecordID]=[RecordID]
EditRecord
SetField
Name: tbl_TEST.StatusChange_TS
Value: =Now()
End EditRecord
I tried the following technique, but it too does not detect a change in the “Status” field with multiple values.
If [tbl_TEST].[Status]<>[Old].[Status] Then
Any help would be appreciated.
Data Macros do not support reading of Multi-Valued fields (or attachment fields). If you were to try to log the values using a LogEvent action you will get the following error ( my field is AllPlans)
The field '[AllPlans]' could not be read because it is a multi-value or attachment field.
I suggest doing it the old-fashioned way, using a sub-table, with Multi-Part Key and multiple data rows. Then deal with the changes in that table.
Art
Related
As the subject expresses, I'm trying to sum the values of a string field where spaces may exist. It must be done this way, unfortunately.
The database is very old. The original developer chose to make all fields Text fields; to get over the null value problems, a function was written in VB6 to replace any null value with a space. This cannot be changed.
Fast forward to now, I'm trying to create a report that sums the length field without changing spaces to nulls first, and it should be done entirely through the control source property of the report.
I've added some of what I've tried below, but every time the report is run, I receive:
Data Type Mismatch
...and I'm not sure how to get around it.
Ideally, I'd like to keep the users out of the database completely, and just add a combo box that lists the reports created in the database so they can be opened by name without having to run any additional update queries first.
=Sum(IIf([MY_LEN]<>" ",DCount("[MY_LEN]","MY_TABLE"),0))
=Sum(Nz(Iif(Trim([MY_LEN])='',Null,[MY_LEN]),0))
=DSum("[MY_LEN]","[MY_TABLE]","[MY_LEN]<>' '")
=Sum(Iif(Val([MY_LEN])>0,[MY_LEN],0))
=(SELECT Sum([MY_LEN]) AS MyLen FROM MY_TABLE WHERE (((MY_TABLE.[MY_LEN])<>' ')))
Is this possible?
Can't compare anything to Null. Can't say If x = Null Then because Null is undefined. So you can't test if undefined = undefined. Use If IsNull(x) Then in VBA and Is Null in query criteria. Don't really need IIf() for Sum() aggregate, other aggregates such as Count or Avg would.
To handle possible space, empty string, or Null for a text field holding numeric data.
=Sum(Val([MY_LEN] & ""))
I have a form with two dependent comboboxes (the second loads its values depending on what is selected in the first one). The second combobox uses this query in its RecordSource property
select... where id = [Forms]![MyForm]![myField]
My problem is that I choose the myField in the expression builder and so it allegedly generates the bracketed part correctly, but when I run the form Access doesn't understand it and always prompts for a parameter named with that expression [Forms]!...etc.
Solved as per post comments by Gustav:
Try specifying the field only: select... where id = [myField].
I am trying to determine how a file path value on a shared server (output of the DLookUp function in Access) is getting populated.
I have a field on a Form that is getting it's Control Source from the following formula:
=DLookUp("[DefaultOuptputDir]","Defaults")
When I search in the VB Editor, I can not find any references at all to "DefaultOuptputDir" (the spelling is correct as it was originally created). I can also not find any reference to the actual Path being populated below, so I don't believe it is hardcoded in a form.
Ultimately I want to change this path to one I can access, but I need to understand how this is getting populated now. Looking for input on what I should be checking, thanks!
DLookUp is a function which searches table for some criteria and returns some field
DLookUp(field, table, criteria)
In your case it shows value of DefaultOutputDir in table Defaults and i suspect this table have only one row so the third argumet is ommited.
That will be the value stored in the first record of a field called DefaultOuptputDir In a table called Defaults.
I have a table with many data rows. This table contains the field "title".
Some of the data rows have already something predefined in that field and the other data rows have this field empty.
My goal is to create a form where users can do the following for every data row: If the field "title" is filled, this field can't be edit. If the field "title" is empty, the user can write something in this field.
I haven't found a solution yet. I tried with calculated fields but these can't be edited.
Also this table and form are for web access, so the possibilities are limited.
Thanks in advance.
Run embedded macro in form OnCurrent event to execute SetProperty action. Use it inside an If Then Else conditional to set Enabled property.
If IsNull(Forms!formname!controlname) Then
SetProperty
ControlName: your control name
Property: Enabled
Value: True
Else
SetProperty
ControlName: your control name
Property: Enabled
Value: False
End
This code assumes field will not have empty string. I do not allow empty strings in fields.
I've searched the web and this site but have not seen an answer to my particular question. I want to produce a report based on the current record (easy), but with the primary key as the Where Condition (not so easy). I'm hoping to use the macro builder and avoid VBA, if possible.
In the macro builder, I can easily get this done by inputting "[First Name]=[Reports]![Contracts]![First Name]" in the Where Condition. 'First Name' is just a regular field present in both my main table and the report. However, customer names can change easily so I'm hoping I can use the primary key "Id", as that should be a more reliable and unchanging value. But if I try with "[Id]=[Reports]![Contracts]![Id]", I get the whole 'Enter a Parameter' dialog (and even if I input the Id value, it just outputs every record).
Why does this work with the First Name field but not the Id field? Is it because Access doesn't like to use primary keys for the Where Condition? If I use the expression builder, Access will recognize the Id field as present in my report and (therefore, I would think) as usable for this purpose. I'm assuming I'm missing something on the left of the equal sign? I've tried with Me. and Me! before and inside the brackets, but nothing. I've also tried stuff like "[Tables]![Main]![Id]=[Reports]![Contracts]![Id]" and "[Main]![Id]=[Reports]![Contracts]![Id]".
You could try creating a temporary variable and pass that to the open report action.
For example, let's say you want to open a report for a record when the user clicks on the field 'First Name' for that record in datasheet view. Your On Click embedded macro would be:
SetTempVar
Name tmpID
Expression = [Id]
OpenReport
Report Name Contracts
View Report
Filter Name
Where Condition = [Id]=[TempVars]![tmpID]
Window Mode Dialog
RemoveTempVar
Name tmpID