Sub NewRecordMark(frm As Form) Dim intnewrec As Integer intnewrec = frm.NewRecord If intnewrec = True Then MsgBox "You're in a new record." _ & "@Do you want to add new data?" _ & "@If not, move to an existing record." End IfEnd Sub
在以上的实例中我有两个问题。
1、在实例中,form作为参数应该用什么写法来表示?
如:forms("xxx")还是直接xxx
2、这样的对象不存在我应该用哪个关键字作为判断字符?
如:If forms("xxx") Not Exist
2、判断带入的窗体是否打开(从函数看,需要对某个打开的窗体进行设置,所以不是判断存在而是判断是否打开),我一般写一个自定义函数来解决:
function FormOpen(formname as string) as boolean
dim frm as form
FormOpen=false
for each frm in forms
if frm.name=formname then
FormOpen=true
exit for
end if
next frm
end function