continous form

roh_8_it_3

Registered User.
Local time
Today, 13:46
Joined
Feb 15, 2005
Messages
79
Hi all,

I m new to access.I have a subform that is bind to a datatabel.I have provided buuton add and undo record to the user.

On the click of the add button i have written this code.

On Error GoTo Err_cmdAdd_Click

' Save any existing changes
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
' Add record, go to it
DoCmd.GoToRecord , , acNewRec
Me!cmbTasklist.SetFocus

Exit_cmdAdd_Click:
Exit Sub

Err_cmdAdd_Click:
MsgBox Err.Description
Resume Exit_cmdAdd_Click

but if i clicks on it it says that acsaverecord method is not avialable now.In my other form its working fine.

I have another question also.How can i force the user checks in a continous form??Suppose if user enters value in the first textbox and closes it it saves it into the database but i want user to fill all the textboxes.so on which event i can apply these checks??

Thanks a lot
 
Is your [Add] Button on the Parent Form or on the Subform?

If it is on the Parent Form, is the Parent Form bound. If it is not bound, the Save command will give you the error you received.

If the above is true, you must first set focus in the subform before you save.

Add Me![SubformFieldName].SetFocus before the save command.

Also if you are using a new version of MS Access, you might prefer to use newer version of the save command.

DoCmd.RunCommand acCmdSaveRecord

Good Luck
 
Thanks,

No the buttons are on the subform.Yes i m using new version of access.

any solutions for the second questions also??
 
You can put tests for required fields in the Form_BeforeUpdate Event. For example here is some code examples


Form_BeforeUpdate(....)

If IsNull(Me![TestField]) Then
strMsg = "Test field is required. Enter it before continuing. "
msgbox strmsg
cancel = true
exit sub
End IF


the cancel = true cancels the Form_BeforeUpdate event and returns to the form. However the cancel generates an error 2501 so you will need to trap for this in your error handler.

If err = 2501 then exit sub

Let me know if you have any more questions.
 

Users who are viewing this thread

Back
Top Bottom