Creating multiple records from one form (1 Viewer)

Well,

you've been working with Craig so long on this that I thought I would say that you are not going about it the right way (as far as the file that I've seen).

The reason - you can't assign a value to a field (me.txtExpenseAmount) and have it result the way you want it if the records have already been entered!

From what I saw, the records are entered when you press the "Save" button, right?
 
Well,

you've been working with Craig so long on this that I thought I would say that you are not going about it the right way (as far as the file that I've seen).

The reason - you can't assign a value to a field (me.txtExpenseAmount) and have it result the way you want it if the records have already been entered!

From what I saw, the records are entered when you press the "Save" button, right?

they were yea. now they are saved on entry... so i see your point.....

is there a way that the txtbox can do calculations? ie if i enter 45/4 it will give me 11.25??
 
is there a way that the txtbox can do calculations? ie if i enter 45/4 it will give me 11.25??
Of course there is, just enter that in the friggin' code line!! :D :D :D

I wish I knew how much you have veered off the road here, so I could give you some more advice on the subject.

Are you just trying to split the "expense" field VALUES into the total expense that is incurred / the number of record entries?

Thus, allocating the correct cost (per record) to equal the total amount of cost incurred??
 
Of course there is, just enter that in the friggin' code line!! :D :D :D

I wish I knew how much you have veered off the road here, so I could give you some more advice on the subject.

Are you just trying to split the "expense" field VALUES into the total expense that is incurred / the number of record entries?

Thus, allocating the correct cost (per record) to equal the total amount of cost incurred??

yea. ill post up the "fresh" db for ya. give me a minute
 
Last edited:
Of course there is, just enter that in the friggin' code line!! :D :D :D

i have tried this, but it only gives me errors, should the format of the field be set to somethign other than currency
 
so you've given up on the multiple-record entry?

Now you don't have any spaces for the order id's. What happened to the combos (casenumbers?)???
 
You changed everything dude. I am not in the "disecting" mood today, you got any explanation on this?
 
no i do have them. they are located at the bottom, of the form instead of the top
 
I meant the comboS. You only have one now. There used to 5 different ones, to allow for the multiple-record entry. Why only one now?
 
if you select one, more show up. its a continuous form
 
Ray, could you save the file as AC2000 format? That way I could open it and take a look at what you have done. Otherwise I'm shooting in the dark.

However, if you have a bound control in your main form that obtains a value that is calculated and depends, in part, on the number of associated records in the subform (which changes every time you add a record) then here's one way of going about it. I'm assuming you have a subform bound to the table ExpensesCodes that has an invisible control bound to ExpenseID (txtExpenseID) and a visible combo bound to CodeID (cmboCodeID).

In the after_update event of the subform put something like

Me.Parent.ExpenseAmount = Me.Parent.txtExpenseAmount / Nz(DCount("ExpensesCodesID","ExpensesCodes","[ExpenseID]=" & Me.txtExpenseID),1)

One other thing, with regard to using recordcount in your recordset attempt....you might need to do a .movelast before obtaining the recordcount otherwise you might not get the correct number of records.
 
Last edited:
here it is in 2000 format
 
Last edited:
i tried the code in the afterupdate of the subform, and it saves, but its saving the value in the txtexpenseamount box, its not dividing by the total number of entries.

here is the code with the changes to match the fieldnames
Code:
Private Sub Form_AfterUpdate()
Me.Parent.ExpenseAmount = Me.Parent.txtExpenseAmount / Nz(DCount("ExpenseCaseID", "ExpenseCase", "[ExpenseID]=" & Me.txtExpenseID), 1)
End Sub
 
Last edited:
Ray, see the attached db.

First up....your textbox on the subform was named ExpenseID not txtExpenseID which was the first problem with the equation.

I also didn't understand that you were taking the Expense value from the same control that you were returning the value to. That requires a modification to the code so that the calculation can determine what the starting total was even after the value has been changed.

For example. If the starting total was $600 and we add code 1 then nothing changes right?

Then we add code 2. The value changes to $300 correct?

Then we add code 3. The old equation would take 300 and divide by 3...equals $100. Which I believe is incorrect.

So, I modified the equation to first work out the original total based on the current value and the number of records before the new code was added, then I divide this number by the new count of records.

Also, the after update event does not appear to fire when you delete a record from the subform. So I added a delete button onto the subform that does the math in reverse (in case you or a user needs to delete one of the codes).

I also threw on a little command button to save the user typing in the current date if they want to use today's date. However, you probably ought to look into a calendar date picker to make this easier for the users.

Note: You will either need to tell the code what to do if the user has not entered the value prior to entering the codes, or prevent the user from entering codes until they have entered the expense value.
 

Attachments

Craig,
Got it working finally. and it works good. now im onto the main timesheet entry portion that i now also have to change to be able to do the same thing.... argh... for some reason though i am unable to select anything on my subform after i entersomething in my mainform box... confused, but im going to keep trying. ill post back if im really stuck. thank you very much for your help

oh and adam... you too!!
 
Sure thing Ray. Glad we got that part sorted out at least :)
 
alright i said if i got stuck id be coming back.. and here i am..

if i start out changing the value on the subform its fine... which i dotn want it to be,
but if i add a task, date then try to assign it to a case, my subform ceases to allow me to change it.
any suggestions?
 
Last edited:
I've fallen behind now Ray, I can't get back in. I'll just wait until you two guys screw it up again. :)

Although, Craig IS competent, so I might not get my wish!
 

Users who are viewing this thread

Back
Top Bottom