Using DLast Or DMax Functions Within SetValue Action In Macro
Oct 28, 2012
I am building a purchase requisition (PR) database.
The tables are (simplified) as follows:
Table1 - tbl_PRList - contains only 3 fields with one of these fields being the "PR No".
Table2 - tbl_PRData - contains all the item data, also with a field "PR No".
The intent of the "item entry" form is to add items to the latest PR that has been generated.
So, whenever an item that is to be placed on the new PR, you type in the item description, qty, etc in the form and then you press a button that saves this item to the main 'data' table (Table1). What I would like to do is, "on click" of this button, I'd like this record, prior to it moving to the next record, to set the value of the PR No field in Table 1 to be the same as the DLast value of the Table2 table.
View Replies
ADVERTISEMENT
Apr 23, 2013
Is there a way to increase the maximum characters allowed in an expression of a macro setvalue action ?
I have an expression in a macro setvalue action that adds multiple form textbox values. I need to change the form name from "RATING ENGINE 2" to "E RATING ENGINE 2". When I do this, I exceed the maximum characters allowed in the expression. Is there a way I can rename "RATING ENGINE 2" without this problem. The expression is as follows:
[Forms]![RATING ENGINE 2]![Excess Liab Premium 6]+[Forms]![RATING ENGINE 2]![Excess Liab Premium 7]+[Forms]![RATING ENGINE 2]![Excess Liab Premium 8]+[Forms]![RATING ENGINE 2]![Excess Liab Premium 9]+[Forms]![RATING ENGINE 2]![Excess Liab Premium 10]
View 6 Replies
View Related
Aug 16, 2004
I have set up a form to use for entering and specifying report criteria. I followed the instructions from general Access help. Everything worked fine in MS Access 2000. Now, I've transferred the database to a computer using MS Access 2003 and I get and error that says, "You entered an expression that has an invalid reference to the property Visible. The property may not exist or not apply to the object you specified." If I change the Macro for the "OK" button from Action="SetValue", Item="[Visible]", and Expression="No" to Action="SetValue", Item="[Forms]![frmParameterQuery].[Visible]", and Expression="False", which I though may be the correct way to enter this for the newer 2003 version of Access, then I get a different error message that reads, "You don't have the license required to use this ActiveX control. You tried to open a form containing an OLE Object or an ActiveX control or you tried to create an ActiveX control. To obtain the appropriate license, contact the company that provides the licensed OLE Object or ActiveX control" Please help!
View 3 Replies
View Related
Sep 15, 2004
Ok. I have a database which tracks the sales and wherabouts of my artwork. Mostly I sell works on a sale or return basis, so I have a form which finds the delivery and opens the delivery details in a subform. This way I can tick off individual items in the delivery as they sell.
I also sell things outright. However, when I am paid for these sales, I want to be able to tick a 'sold' check box in the main form which then automatically fills in the date sold field (on both form an table) as the current date for all the items in that delivery, i.e. I want to tick the box once in the form causing the date to be entered into each record in the subform automatically.
I have tried making a command button on the form with a SetValue macro. I cannot get this to work with a date (maybe I have got the expression wrong) and also it only works with the first record on the subform.
Can anyone solve my problem or do I just have to be patient and enter each date individually?
View 2 Replies
View Related
Nov 15, 2006
Hello all,
I am currently using the SetValue function from within a macro to set the value of one text box to the value of another. It works fine under full version but when I use it under Runtime which is where the final application will be run from, it brings up the Halt box and will not continue the macro.
Does anyone know what can/cannot be done within Runtime. Is it just the same as A full version but without Design functions or are some other functions removed. I am painstakingly having to go through all the vba code that I wrote in full version and I am having to change so many things in order for it to work with Runtime. This is a real pain the backside!
Any thoughts would be huuuugely appreciated.
Thanks all!
Gareth
View 1 Replies
View Related
Sep 17, 2014
I have inserted a function via a module at the beginning of a Macro using the RunCode action:
Function Msgbox_Yes_No()
Dim Response As Integer
Response = MsgBox(prompt:="Select 'Yes' or 'No'.", Buttons:=vbYesNo)
If Response <> vbYes Then
End If
End Function
However, it doesnt stop the macro from continuing on its way to delete a load of records if the user chooses no.
View 3 Replies
View Related
Jan 9, 2014
I want to run a macro which is having three action queries from the another database when i click the button from my current database. I am using Access2010.
View 3 Replies
View Related
Sep 21, 2011
Why when I set up a macro with a PrintOut action does it always prompt me to "Save As" before it prints? I have a default printer set up in the system, but it still asks to "Save As." It does print after.
View 1 Replies
View Related
Aug 6, 2004
I have a Macro setup and SendObject is one of the Actions. It is setup to send an existing report. Is there a way to insert a fieldname from that report into the Subject line of the e-mail that is sent? That would be great, instead of having the same subject line for every e-mail, using the date or something like that. Please let me know. Thanks.
View 3 Replies
View Related
Jan 12, 2015
One of the users of my application, reports an error when saving a report to pdf by VBA code. She’s using Access 2013, on Windows 8.1.
The error is “error 2501 output to action was cancelled with access vb macro”
The VBA code is
StrReport = “RepInvoice”
StrDocumentName = “C:UsersMaryDocumentsAccessInvoice.pdf”
DoCmd.OpenReport StrReport, acViewPreview
DoCmd.OutputTo acOutputReport, StrReport, "PDFFormat(*.pdf)", StrDocumentName, False
DoCmd.Close acReport, StrReport, acSaveNo
This error occurs at the OutputTo line. This code is part of an user form with a button “save as PDF”.
When this code is run, the report is visible as an example (as meant to be) on the screen. The code stops at the OutputTo line.
When I use
DoCmd.OutputTo acOutputReport, StrReport, acFormatPDF, StrDocumentName,, False
the problem still exists.
I tried to save the report manually by Preview > Export > PDF. The preview is OK, saving as PDF results in the same error 2501. This may lead to the conclusion that this problem is not caused by the VBA code.
I verified whether user write rights are OK, and whether a default printer is available. Both are OK. The report consists of 1 page.
When this very same application is used with Access 2010, everything functions as expected.
View 8 Replies
View Related
Feb 5, 2006
Iam traying to get result of my record as below
If next record is biger show "1"
If next record is smallest show "0"
If next record is the same Show "---"
I have used the following formulla in query
Res: IIf(Nz([Price]-DLast("[Price]","[tt]","[id]<" & [id]),1)=0,"-----",IIf(Nz([Price]-DLast("[Price]","[tt]","[id]<" & [id]),1)<0,0,1))
When I use the query it gave me wrong result.
I have attaced the DB for your reference and correction :
the query will ask to enter a code : Please enter code: 1020,1030 or 1010
any one can give help to solve this issue?
thank you
View 14 Replies
View Related
Jul 9, 2013
I have used a form for years and DLast worked. But all of a sudden DLast is returning a record in the middle of the table from 2 years ago. One is a text box. One is a List Box. Both are getting the wrong record. All other forms using DLast on different tables are working OK.
I haven't changed the form.
=DLast("[DebitCredit]![DCDate]","[DebitCredit]")
What happened?
View 5 Replies
View Related
May 15, 2014
I'm trying to generate a list of employees who haven't had a review since Dec 2013.I'm using this expression in my query:
Last review: DLast("[ReviewDate]","[Tbl_OutcomeHistory]")
which brings up the last date the employee had a review.(I tried using DMax but it didn't seem to like dates?)How do I get it to just show those who haven't had a review since 1st Dec 2014. I thought I could use "<01/12/2014" in the criteria but it returns no values. I've tried to drop the date into the expression but that returns no values.
View 12 Replies
View Related
Feb 19, 2008
I've linked my inventory database to a table that holds data for my web site. Using a macro I can transfer the data in several field at the click of a button. I've run into a problem with one field called [SizeW] in my inventory and [width] in the web site db. [sizeW]is in meters and [width] needs to be in centimeters so I made my macro expression [sizeW]*100. The trouble is I get an incorrect result. 0.87 becomes 87.0000004768372 and so on. I have tried setting the format in the web site db to General Number and 0 decimals but this doesn't work. I can't think of anything that could be the cause.
Any possibility this could be caused by a naming issue? I think 'width' might be a reserved terem for access.
View 4 Replies
View Related
Jun 22, 2005
I'm trying to create a database that we can use to track Vacation, Sick, and Personal days. It's a very simple setup, for each option I have a start value a place to enter the amount used and and expression field that calculates the time remaining.
My query calculates the difference (Expr1: timelosstbl!SickBeg-Timelosstbl!SickAccUsed)
but this value isn't stored, since it runs everytime the query is run. So I have another field that (SickTotal). I have a button that on click it runs a macro and I use the SetValue action and it takes the value in the expr1: field and copies it to the SickTotal field. I have another button that on click runs basically the same macro that copies the value in the SickTotal field to the SickBeg field. My problem is that when I click the button everyting works but I doesn't remove the figure that was manually entered in the SickAccUsed field. So what I thought I needed to do was instead of using a macro to run the procedure I'd do it as an event procedure but I don't know how to recreate the macro because when I do either me. or docmd. setvalue isn't an option.
So basically what I need is
A=starting figure, B=manually enter hours used, C=remaining time, D=stored value for C
A - B = C, C = D on click make A = D and clear B
Confused?
Thanks,
Rick
View 4 Replies
View Related
Jun 17, 2005
I have two Combo boxes which work as selection boxes for the detail form. So, if one Combo box selects Name - the detail form is filled with the information belonging to that Name...
However, I have two combo search boxes: one for Name and one for Clientnumber. They both work fine, but I would like to reset the first combo box if the other one is used and vice versa.
So, basically, my question is: how do I reset a combo box in a AfterUpdate (right?) event of another combo box?
View 3 Replies
View Related
Jan 2, 2007
Currently using an IsNull expression to Setvalue of a field to Invisible but rathe than type the condition,action,item,expression form every field i want to make invisible, can I list fields and attach to one ISNull condition, if that makes sense?
Currently have:[Stk Entitlement ID2].[Visible], but would like to add other fields like:[Stk Entitlement ID2],[Stock ratio 2],[Stock Entitlement 2].[Visible].
View 3 Replies
View Related
Mar 30, 2012
I am having issues with the SetValue macro. Basically, my database is for HR and uses a series of forms to enter a new hire, and to export this new hire to excel for a data upload. The weird thing is that it worked before, then all of a sudden, it gave me error 2950 while trying to run a macro which had a few SetValue functions.
I went to another form to see if that one worked w/ SetValue (because the database is trusted in my system), and it did. So my problem is that I'm receiving error 2950 (trust issues) in one form, but not receiving the same error, from the same function, on another form.
View 2 Replies
View Related
May 27, 2005
I have a main form FrmQuote that has 2 Subforms. The 2nd subform FrmCalculateQuote is based on a calculation query. In order to save a calculated value I have another Table/Form (FrmSCQuoteOverviewUpdate) that records the quote value calculated in the subform FrmCalculateQuote (text34)
The following forms are open FrmQuote FrmSCQuoteOverviewUpdate and subform FrmCalculatequote.
In the subform FrmCalculatequote I have created a button click event that should set the value of [tot contract cost] in FrmSCQuoteOverviewUpdate
to text34 in the subform
Forms!FrmSCquoteoverviewUpdate![tot contract cost] = forms!Frmcalculatequote![text34]
when runnng the code I get the error message "run time error 2450..can't find the form FrmCalculatequote.."
It seems that the problem is in calling the subform just forms!....
Can somebody please help me with the code to refer to a subform.. :confused:
View 3 Replies
View Related
Dec 22, 2011
Is it possible to use the SetValue macro action to set field criteria in a query? I've done this in the past by creating a form, using SetValue to set a value for a form field, then having the field in the query read from the form field.I noticed in the expression builder under the SetValue action that it allows you to select query fields directly though.
View 1 Replies
View Related
Dec 9, 2013
I'm using A2003 (yes, still). An accounting type form requires the "Type" be entered as either (numeric) 1, 11, or 2. On the same form, one of the three Yes/No fields must be checked as confirmation.
My hope is that I can use the "SetValue" action in a macro.
My first attempt (to set the "Assiniboine" field to "Yes" or "On"):
Item: [Forms]![DisbursementMade]![Assiniboine]
Expression: IIf([Forms]![DisbursementMade]![Type].[AfterUpdate]=1,Yes)
That isn't doing anything for me.
The default value for the "Type" field would normally be 1 (but that presumes the user will not skip past it without confirming it) so I have no default value.
The other two Yes/No fields would also be Set by the same logic: (if Type=11, [Bank]=Yes) (if Type=2, [PettyCash]=Yes)
Alternatively, I've tried the reverse approach: If [Assiniboine]=Yes, SetValue of [Type] to 1 so far without success. I'm not using VBA, since the bookkeeper changes from year to year and there is no Administrator. Although the computer has A2010, and can run an .mdb file with macros, successfully, making changes within A2010 produces an 'embedded macro' that isn't readable in A2003.
View 2 Replies
View Related
Dec 8, 2013
I am trying to write a more complex macro that will start another macro at a preset time, however I am getting stopped at the first hurdle - getting a macro to run another macro.
Here is the code i am using at the moment, all I want to do currently is click the first button, then get the second macro to execute. But no luck, getting error 2157 "cannot find the procedure"
Code:
Private Sub Command3_Click()
MsgBox "1st macro running", vbExclamation, "Note"
Application.Run "teststart1"
' Application.OnTime TimeValue("19:55:00"), "teststart1"
[code]....
View 1 Replies
View Related
Oct 10, 2014
I don't know, I have noticed that the SETVALUE argument is not openly available in the lookup tables when setting a macro. (But that aside) I have set my drives c: and d: as trusted, and also thicked the sub folder option.
View 7 Replies
View Related
Sep 15, 2006
Thanks for all the help to date.
Problem trying to get a dmax field for an invoice no in a query - am doing something wrong current attempt below won't work
Expr1 :dmax([Invoice no],[Table name]![Invoice no])
what am I missing - do I need something on the end when I get this to work I will use it to add 1 for the final query prior to print
View 4 Replies
View Related
Dec 21, 2006
Okay...I know the basic syntax for Dmax (or at least I thought I did) but I cannot get this statement to do what I want!
In the <before update> event I tyoed this:
Dim RNum As Long
Me.txtRNumber = DMax("[Request_Num]", "test_request") + 1
Me.txtRnumber = RNum
txtRNumber is the field on the form
Request_Num is the field on the table
test_request is the table
yes...I know the name syntax is bad (it's an older db I'm using as a test for a newer one).
Obviously, I want to automatically increment the field value by 1 on every new record (an if newrecord clause is included). But I just can't get the stinkin thing to work!!!
View 12 Replies
View Related
Oct 3, 2006
I am having difficulty understanding under which circumstances I should be using Max() as opposed to DMax() functions. Both seem to do the same thing (find maximum value in a field), but DMax has additional arguments.
What I currently want sounds like neither of these, as I want to query the maximum of several values in various fields for a specific record, rather than the maximum of several records in a specific field. Is there a way of doing this otherwise than by nesting IIF functions several deep?
I keep running into "Microsoft Office Access has encountered an error and needs to close" error messages, and am coming around to the view that I may need a UDF. I have never done one in Access before (but did some time ago in Excel).
Currently I have fields in various tables:
T_Clients.Commencement
T_Clients.Cessation
T_Tasks.StartDate
T_Tasks.EndDate
There is a one (T_Clients.ID_Clients) to many (T_Tasks.ID_Clients) relationship
T_Clients.ID_Clients and T_Tasks_ID_Tasks are primay keys.
In "pseudocode" my query, probably via a UDF, needs to return:
Min(Max(StartDate,Commencement)+12months,Min(EndDa te, Max(Cessation,StartDate))+9months
Commencement and Cessation may contain Null values, which are then to be treated as #1900-01-01# for the purposes of any comparisons.
My first attempt at this was to create several queries, each based on the previous query. Inefficient, perhaps, but I could trace the logic. I started by creating queries that substituted #1900-01-01# for null values in the Commencement and Cessation fields.
However when I got about 3 queries deep I ran into the "Access has encountered an error and needs to close" error, and no amount of playing around with it stopped that.
I don't know if relevant but I don't *really* have a T_Tasks.StartDate field. I have a query that calculates the start date from the previous EndDate, but I did not want to complicate the problem specs. That query seems to work ok. If I get a solution to the above I hope to jigger it to fit.
View 3 Replies
View Related