Add New Record

M

MikeJohnB

Hi again, I struglle with access vba but am more than proficient with Excel
which is why I get frustrated. Having said that, I have the following code.

Private Sub Command26_Click()
Me.Qty_Low = DMax("[Qty_High]", "Tbl_Price_Break", "[Record_Number]=" &
Me.Record_Number) + 1
Me.Qty_Low = DMax("[Qty_High]", "Tbl_Price_Break", "[Record_Number]=" &
Me.Record_Number) + 1
Me.Function = DLast("[Function]", "Tbl_Price_Break", "[Record_Number]=" &
Me.Record_Number)
Me.Part_Price_GBP = Me.Function * DLast("[Part_Price_GBP]",
"Tbl_Price_Break", "[Record_Number]=" & Me.Record_Number)
Me.Exchange_Rate = DLast("[Exchange_Rate]", "Tbl_Price_Break",
"[Record_Number]=" & Me.Record_Number)
Me.Part_Price_Euro = Me.Part_Price_GBP * Me.Exchange_Rate
Me.Qty_High = Me.Qty_Low + DLast("[Qty_High]", "Tbl_Price_Break",
"[Record_Number]=" & Me.Record_Number) - DLast("[Qty_Low]",
"Tbl_Price_Break", "[Record_Number]=" & Me.Record_Number)
Me.Refresh


End Sub

This code makes several calculations and populates fields with the results.
This works well but when the button is pressed to "Fill Breaks" the focus
stays with the current record which means that pressing the button again re
calcs the same record. I am not sure how to move the focus to a new record on
the sub form and a specific field? I have tried requery and recalc which have
the opposite effect of going to the first record.

Further, my subform is called Frm_Price_Break subform, while the button for
firing the calculations is on this form, why cant I select this form, would
it be because it needs the full form path?
Form!Frm_Main_Quotation_Data!Frm_Quotation subform!Frm_Price_Break subform to
select the ast subform????

Can anyone assist?????
 
M

MikeJohnB

Ahhh, something noticed, the button which fires the code to do the
calculation is on the form header of a continuous form so I guess the
question should be, how do you move focus from the button to the subform
data? I still have the same problem with trying to set focus to the form
using Forms. for some reason, even though the button is on the actual
subform, it don't know the subform is there??? I am stuck, any help much
gratefully accepted
 
M

MikeJohnB

Have sorted out one thing, removed the tabstop from the button now the
subform retains focus but I still cant select a control in vba, it says the
subform is not open even though the cursor is in the new field of the
subform. Pressing enter through all the controls manually cycles through the
same new record without adding a new one. Is this because I have not added
any data to a control? A new record pops up and if data is added, the problem
is, I have all the code working except for this last little bit.

The code predicts what is to be entered in all fields based on the first
entry, could I send someone the db zipped?
 
M

MikeJohnB

Please ignor this question, I have now sorted everything out and all works
great, the row missing from the code was:

DoCmd.GoToRecord , , acNext

Which of course takes me to the next record.

Thanks anyway
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top