Record will not save

aikiai

Registered User.
Local time
Today, 09:48
Joined
Jan 26, 2005
Messages
17
Can't figure it out. Here is the code:


Private Sub Button_OpenQuest_Click()
On Error GoTo Err_Button_OpenQuest_Click

DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Ques_Physician"

stLinkCriteria = "[sbjID]=" & "'" & Me![sbjID] & "'"
DoCmd.OpenForm stDocName, , , stLinkCriteria

Me.Visible = False

Exit_Button_OpenQuest_Click:
Exit Sub

Err_Button_OpenQuest_Click:
MsgBox Err.Description
Resume Exit_Button_OpenQuest_Click

End Sub

____________________________________________________

I get the message "The command or action 'SaveRecord' isn't available now"
 
Your code from the wizard is archaic.

Code:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenForm "Ques_Physician", , , "[sbjID]=" & "'" & Me![sbjID] & "'"

Me.Visible = False
 
ghudson said:
Your code from the wizard is archaic.

Code:
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord

DoCmd.OpenForm "Ques_Physician", , , "[sbjID]=" & "'" & Me![sbjID] & "'"

Me.Visible = False

This code does not seem to work. I am at a lost as the popup box saids the SaveRecord not avaiable now.

Just some additional background info. There are more then 1 tables connected to this form. I don't know if that has anything to do with it.
 
There are more then 1 tables connected to this form. I don't know if that has anything to do with it.
That is most likely your problem. The relationships and referential integrity might not allow you to do what you want.
 
ghudson said:
That is most likely your problem. The relationships and referential integrity might not allow you to do what you want.

Any solutions?

The only other table linked is by a common variable and the other table only has six variables. Is there something in the order that I put the code in my program?

If I take out the save record statement then the button I created does the job I need it to do. Should I close the current form instead of hide the form?

Any help would be appreciated.

Thanks
 
Okay I figured it out. Apparently there is a data entry lock on the form. Until I unlock the form for data entry then I get that error. Now I have a different problem.

According to my goal I am trying to say if the race is 6 then popup a form. however what happens is that I get a runtime error message.


Private Sub sbjRACE_AfterUpdate()

If Race.Value = 6 Then DoCmd.OpenForm "Ques_Physician", , , "[sbjID]=" & "'" & Me![sbjID] & "'"
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdSaveRecord
End

End Sub
 
Try...

Code:
Private Sub sbjRACE_AfterUpdate()
 
DoCmd.RunCommand acCmdSaveRecord
 
If Race.Value = 6 Then DoCmd.OpenForm "Ques_Physician", , , "[sbjID]=" & "'" & Me![sbjID] & "'"
 
End Sub
You need to save the record before you open the other form. You will have to do something in the BeforeUpdate of the first form just incase there is an error [duplicate record/value ?] when trying to save the record.
 
Be consistant in how you reference form fields. The "Me." syntax is prefered. ".Value" is optional.

If Me.Race = 6 Then DoCmd.OpenForm "Ques_Physician", , , "[sbjID]=" & "'" & Me.sbjID & "'"

ID fields are generally numeric. If sbjID is numeric, then you need to change the statement to:

If Me.Race = 6 Then DoCmd.OpenForm "Ques_Physician", , , "[sbjID]= & Me.sbjID
 

Users who are viewing this thread

Back
Top Bottom