Avick
09-10-2001, 01:12 PM
I hope someone can help. I have a form that is based on a table and a second form that is based on a query. On the first form the person will enter information such as paper lenght and box's produced. When they click a button "Calculate" It takes them to a second form that will display the calculations for the first form. It works OK but when i enter a new record and click "Calculate" the second form is blank. Is there any way i can save the record and open the calculate form in one button click and view my results.
Thank you in advance.
jwindon
09-10-2001, 03:04 PM
You should have the second form close each time it is used. Otherwise, it will not requery without being told to do so. My suggestion is that the buttonclick (commandbutton) be set with code to:
DoCmd.Save "frmForm1"
DoCmd.OpenForm "Form2", acNormal, , , acEdit
Avick
09-12-2001, 12:25 PM
I have tried this to no avail. I get a message "Type mismatch"
Here is the code.
Private Sub calculate_Click()
On Error GoTo Err_calculate_Click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.Save
stDocName = "calculate"
DoCmd.Save "Batch Costing"
stLinkCriteria = "[ba_id]=" & "'" & Me![ba_id] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_calculate_Click:
Exit Sub
Err_calculate_Click:
MsgBox Err.Description
Resume Exit_calculate_Click
End Sub
The First form is called " Batch Costing " and the secound is "calculate"
The idea is that when i enter a new record in "Batch Costing" it will calculate in "calculate" The first form is coming from a table and the second is coming from a query that runs the calculation.
DoCmd.RunCommand.acCommand, SaveRecord
Use a macro to build the statement and then convert it to vb for the correct syntax.
HTH
Avick
09-15-2001, 04:23 PM
Thanks for that. It now works the way I want.