![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
This is basically a macro I guess but I'm so rusty I can't quite think how to start. When my form opens focus is set to a textbox in the first row within a subform. I just want to calculate the difference between two other columns (also displayed on the subform) and then have that figure be automatically entered. This will be the same as if a person was entering the data (the afterupdate code would then run which is important). Then I want the return key to be pressed so that the focus shifts to the textbox in the next row. Then repeat til we hit the bottom and trap that error. Ultimately I want to set this in motion from a command button and the form will be opened and then shut invisibly. The reason for the automation is to quickly fill out these figures when we're in a hurry. Normally the user will do it line by line but this scenario needs to be supported. Any quick tips on how to proceed? thanks |
#3
| |||
| |||
|
|
What are you trying to accomplish by calculating and storing into a Text Box Control on the Form embedded in the Subform Control? The simple way is to use a Query as the Record Source of the Form embedded in the Subform Control... calculate that value in the query. BTW, if the Form in the Subform Control has a Table as a Record Source, and you are storing the value calculated from two other Fields in that Field of the Table, that's a violation of Relational Database design principles and will, sooner or later, cause you a lot of problems. -- Larry Linson, Microsoft Office Access MVP Co-author: "Microsoft Access Small Business Solutions", published by Wiley Access newsgroup support is alive and well in USENET comp.databases.ms-access |
#4
| |||
| |||
|
|
"Access Developer" <accdevel (AT) gmail (DOT) com> wrote in message news:9fkcfnFcshU1 (AT) mid (DOT) individual.net... What are you trying to accomplish by calculating and storing into a Text Box Control on the Form embedded in the Subform Control? The simple way is to use a Query as the Record Source of the Form embedded in the Subform Control... calculate that value in the query. BTW, if the Form in the Subform Control has a Table as a Record Source, and you are storing the value calculated from two other Fields in that Field of the Table, that's a violation of Relational Database design principles and will, sooner or later, cause you a lot of problems. -- Larry Linson, Microsoft Office Access MVP Co-author: "Microsoft Access Small Business Solutions", published by Wiley Access newsgroup support is alive and well in USENET comp.databases.ms-access No it's not that bad. The subform has a table as the source and the field I'm talking about is simply for user input. They can type whatever they like into it as long as it's a value. This is the basis of the program. The other two values are simply Budget and Actual. The user evaluates these and then they enter a Projection into the text box which produces an overall total for the line. All of this works just fine. However I have a scenario for the advanced user who simply needs to produce a report very quickly without performing any input. So for each line we'll look at Budget and Actual. For instance if the budget was $1000 and we've spent $200 so far I want $800 as a projection from now til the end of the year. Thus I want to automatically add $800 into the textbox, hit enter and repeat with the next row. I know I could manipulate the table source directly but I need to have the textbox afterupdate code to fire - I just need to automate entry into the form and all will be well. |
#5
| |||
| |||
|
|
Help me understand... is this simply a field for user entry and the calculation you describe just a 'default value', or is the user entry into the other two fields you mention, is the value stored in the table, are all three values stored in the table? |

|
-- Larry Linson, Microsoft Office Access MVP Co-author: "Microsoft Access Small Business Solutions", published by Wiley Access newsgroup support is alive and well in USENET comp.databases.ms-access "buckskin" <buckskin (AT) mailinator (DOT) com> wrote in message news:9fl0qkF2hcU1 (AT) mid (DOT) individual.net... "Access Developer" <accdevel (AT) gmail (DOT) com> wrote in message news:9fkcfnFcshU1 (AT) mid (DOT) individual.net... What are you trying to accomplish by calculating and storing into a Text Box Control on the Form embedded in the Subform Control? The simple way is to use a Query as the Record Source of the Form embedded in the Subform Control... calculate that value in the query. BTW, if the Form in the Subform Control has a Table as a Record Source, and you are storing the value calculated from two other Fields in that Field of the Table, that's a violation of Relational Database design principles and will, sooner or later, cause you a lot of problems. -- Larry Linson, Microsoft Office Access MVP Co-author: "Microsoft Access Small Business Solutions", published by Wiley Access newsgroup support is alive and well in USENET comp.databases.ms-access No it's not that bad. The subform has a table as the source and the field I'm talking about is simply for user input. They can type whatever they like into it as long as it's a value. This is the basis of the program. The other two values are simply Budget and Actual. The user evaluates these and then they enter a Projection into the text box which produces an overall total for the line. All of this works just fine. However I have a scenario for the advanced user who simply needs to produce a report very quickly without performing any input. So for each line we'll look at Budget and Actual. For instance if the budget was $1000 and we've spent $200 so far I want $800 as a projection from now til the end of the year. Thus I want to automatically add $800 into the textbox, hit enter and repeat with the next row. I know I could manipulate the table source directly but I need to have the textbox afterupdate code to fire - I just need to automate entry into the form and all will be well. |
#6
| |||
| |||
|
|
So, you are looking for something like this for the Superuser to calculate the Projection without any intelligence (whether over or under spending) so that the Projection will be right on to the Budget: (From memory, so syntax may be a little off): Assumes the command button to kick this off is in the subform... with me.recordsource .MoveFirst Do Until .EOF !Projection = !Budget - !Actual .MoveNext Loop End With |
#7
| |||
| |||
|
|
"Ed J." <ed (AT) smbpartners (DOT) com> wrote in message news:d3d92ae7-aebb-465f-8b3e-c8c8b683295b (AT) u13g2000vbx (DOT) googlegroups.com... So, you are looking for something like this for the Superuser to calculate the Projection without any intelligence (whether over or under spending) so that the Projection will be right on to the Budget: (From memory, so syntax may be a little off): Assumes the command button to kick this off is in the subform... with me.recordsource .MoveFirst Do Until .EOF !Projection = !Budget - !Actual .MoveNext Loop End With Er no, not quite. If it was that simple I'd have it covered, thanks though. I guess I'm not making myself understood and I am trying quite hard! This is mostly about form automation. Had a mental breakthrough last night and assuming I get this done today I shall reply to my own post with the solution for sake of anyone else. |
#8
| |||
| |||
|
|
"I know I could manipulate the table source directly but I need to have the textbox afterupdate code to fire - I just need to automate entry into the form and all will be well" You say that the target form wouldn't be visible to the super user and I'm deducing that you don't want to manipulate the table data directly as you want to fire the text box AfterUpdate events one the invisible target form? Firstly I think I'm right in saying if you update a control in code it's AfterUpdate doesn't fire anyway so I don't think this approach is going to work for you. "Ultimately I want to set this in motion from a command button..." So why can't you just update the table directly and run whatever code you had in the target form's TextBox AfterUpdate from this command button (obviously making the code available outside of the form's class module)? Opening a form invisibly just to manipulate it's underlying data or to run code that happens to be in the form's class module is just wrong. I can't think of any scenario where this would be necessary unless you can enlighten us! HTH "buckskin" <buckskin (AT) mailinator (DOT) com> wrote in message news:9foe2lFgvnU1 (AT) mid (DOT) individual.net... "Ed J." <ed (AT) smbpartners (DOT) com> wrote in message news:d3d92ae7-aebb-465f-8b3e-c8c8b683295b (AT) u13g2000vbx (DOT) googlegroups.com... So, you are looking for something like this for the Superuser to calculate the Projection without any intelligence (whether over or under spending) so that the Projection will be right on to the Budget: (From memory, so syntax may be a little off): Assumes the command button to kick this off is in the subform... with me.recordsource .MoveFirst Do Until .EOF !Projection = !Budget - !Actual .MoveNext Loop End With Er no, not quite. If it was that simple I'd have it covered, thanks though. I guess I'm not making myself understood and I am trying quite hard! This is mostly about form automation. Had a mental breakthrough last night and assuming I get this done today I shall reply to my own post with the solution for sake of anyone else. |
#9
| |||
| |||
|
|
I agree with Jon. You are cruisin' toward a bruisin' here, because calculating by automating form operations whether by macros or VBA code is just not the way to try to use Access, and it will cause you grief later. And, it's not clear just what nor why you are storing data, but then calculating it for 'Superuser'. I perceive what you write as a detailed description of how you think something should be done, not the 'what are you trying to accomplish' that I asked for. It also seems that you are overriding what the user has entered, at least sometimes, and are using a field in a table for temporary storage... and that you are determined that you are going to persist in asking how to make 'your way' correct. If you'd back off, describe what data you have, and what you want to accomplish, it's possible that someone might have useful suggestions; otherwise, further discussion is likely fruitless. -- Larry Linson, Microsoft Office Access MVP Co-author: "Microsoft Access Small Business Solutions", published by Wiley Access newsgroup support is alive and well in USENET comp.databases.ms-access |
#10
| |||
| |||
|
|
I'm still having trouble trying to understand your business requirement. On one hand you say "Basically all I'm fundamentally asking for is how to move down a row and enter a figure.", but on the other hand you say that my suggestion of a Do Loop with a MoveNext is not adequate. I don't understand what else you need if that won't do the trick. Just trying to contribute. |
![]() |
| Thread Tools | |
| Display Modes | |
| |