Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error - You can't go to the specified record.

Status
Not open for further replies.

acnovice

Programmer
Jan 27, 2005
100
US
Hi,

I have a problem on my Invoice form with subform.
After I create new Invoice, I got a following message.

"You can't go to the specified record."
If I click "OK", then it says

"You can't save this record at this time."
If I click "Yes" and close the form and go to Invoice table, the data's saved.
It's been generated after I change the code for some fields.

I wanted to store the calculated numbers to Invoice table after I create new Invoice.

Here are my code:

Private Sub saleTotal_AfterUpdate()
CalSalesTotalAmount
End Sub

Private Sub CalSalesTotalAmount()
Me.saleTotal = Nz(sfrmInvoiceDetail.Form![Total Sum], 0)
Me.totalAmt = Nz(Me.saleTotal, 0) + Nz(Me.salesTax, 0) + Nz(Me.FH, 0)
End Sub

I placed the code to each field event and for the entire form both of them.
Did I do something wrong with this ?

I appreciate your answer.
 
IMHO the code is needed in only ONE location: the BeforeUpdate event procedure of the sfrmInvoiceDetail form.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
PHV,

I placed the code "BeforeUpdate" to frmInvoice because
the fields, saleTotal, salesTax, FH, totalAmt are on "frmInvoice"

The "saleTotal" is calculated from "sfrmInvoiceDetail".

Now, it doesn't say "You can't go to the specified record." and looks working fine.

However, the calculated fields don't show up on the "frmInvoice" form immediately. It shows up after I save or move different invoices using navigation button.

What does it make pop-up data right away to form ?
 
did you try something like me.refresh or me.recalc at the end of your code?

HTH,
fly

[blue]Typos, that don't affect the functionality of code, will not be corrected.[/blue]

Martin Serra Jr.
[blue]Shared Database Systems and Applications across all Business Areas[/blue]
 
Perhaps a call to Forms!frmInvoice.Recalc in the AfterUpdate event procedure of sfrmInvoiceDetail

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi again,

flyover789... If try that, I get an "Run-time error 2115:".

PHV... I tried your suggestion but it doesn't change anything at all. It's same as before.

FYI... I'm using update query to calculate price in sfrmInvoiceDetail.

In "sfrmInvoiceDetail" form,
OrderQty / UnitPrice / Total ([OrderQty]*[UnitPrice])
To get a total : Total Sum (=Sum([Total])

Is there a sequence to process the total in "sfrmInvoiceDetail" and saleTotal in "frmInvoice" ?
 
PHV wrote:
Perhaps a call to Forms!frmInvoice.Recalc in the AfterUpdate event procedure of sfrmInvoiceDetail

@acnovice:
try Forms!frmInvoice.Refresh in the AfterUpdate event procedure of sfrmInvoiceDetail

HTH,
fly

[blue]Typos, that don't affect the functionality of code, will not be corrected.[/blue]

Martin Serra Jr.
[blue]Shared Database Systems and Applications across all Business Areas[/blue]
 
flyover789,

I tried that but still no progress.
I will take a look at it more...

Anyway thank you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top