در رویداد form_keydown فرمی که می خواهی کلیدهای فانکشن عمل کنند کدهات رو بنویس
برای راحتی کار میتونی کد زیر رو توی فرمت کپی کنیPrivate Function SaveFunction()
If IsNull(Onvan) Or Onvan = "" Then
MsgBox "لطفا عنوان پروژه را وارد کنيد"
Me.Onvan.SetFocus
Else
If IsNull(Addrees) Or Addrees = "" Then
MsgBox "لطفا آدرس پروژه را وارد کنيد"
Me.Addrees.SetFocus
Else
'If IsNull(Etebar) Or Etebar = "" Then
'MsgBox "لطفا نوع اعتبار پروژه را انتخاب کنيد"
'Me.Etebar.SetFocus
'Else
' If IsNull(Mojri) Or Mojri = "" Then
' MsgBox "لطفا مجري پروژه را انتخاب کنيد"
' Me.Mojri.SetFocus
' Else
' If IsNull(Nazer) Or Nazer = "" Then
' MsgBox "لطفا ناظر پروژه را انتخاب کنيد"
' Me.Nazer.SetFocus
' Else
If IsNull(pol) Or pol = "" Then
MsgBox "لطفا مبلغ پروژه را وارد کنيد"
Me.pol.SetFocus
Else
' If IsNull(Numsaman) Or Numsaman = "" Then
' MsgBox "لطفا شماره درخواست سامانه مهندسي پروژه را وارد کنيد"
' Me.Numsaman.SetFocus
' Else
If IsNull(NumTarh) Or NumTarh = "" Then
MsgBox "لطفا شماره طرح پروژه را وارد کنيد"
Me.NumTarh.SetFocus
Else
If IsNull(InfoPro) Or InfoPro = "" Then
MsgBox "لطفا توضيحات پروژه را وارد کنيد"
Me.InfoPro.SetFocus
Else
'--------------------------------
If IsNull(Moed) Or Moed = "" Then
MsgBox "لطفا موعد تحويل و تحول را وارد کنيد"
Me.Moed.SetFocus
Else
' براي کنترل امتياز دهي مجري پروژه
If Me.TTF.Value = True And Me.Emtiaz.Value = 0 Then
MsgBox "لطفا امتياز مجري پروژه را وارد کنيد"
Me.Emtiaz.SetFocus
Else
On Error GoTo Err_cmdsave_Click
Me.AllowEdits = True
Me.Find.Locked = False
Me.dateRoz.Locked = True
Me.Emtiaz.Locked = True
Me.Sal.Locked = True
Me.Nahi.Locked = True
Me.NumPro.Locked = True
Me.Onvan.Locked = True
Me.Addrees.Locked = True
Me.Etebar.Locked = True
Me.ECOD.Locked = True
Me.ECOD_1.Locked = True
Me.ECOD_2.Locked = True
Me.pol.Locked = True
Me.Mojri.Locked = True
Me.Nazer.Locked = True
Me.InfoPro.Locked = True
'Me.Numsaman.Locked = True
Me.NumTarh.Locked = True
Me.Moed.Locked = True
Me.TTF.Locked = True
Me.DateMostanad.Locked = True
Me.Tavil.Locked = True
Me.cmdFirst.Enabled = True
Me.cmdnext.Enabled = True
Me.cmdPre.Enabled = True
Me.cmdLast.Enabled = True
Me.cmdnew.Enabled = True
Me.cmdnew.Visible = True
Me.cmdDel.Enabled = True
Me.cmdedit.Enabled = True
Me.cmdcancel.Enabled = False
Me.cmdcancel.Visible = False
FirstPage.Enabled = True
ReportPage.Enabled = True
Me.cmdsave.Enabled = False
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
Emtiaz.Value = Frmsabt.Recordset.RecordCount
Frmsabt.Refresh
Exit_cmdsave_Click:
DoCmd.GoToRecord , , acLast
Exit Sub
Err_cmdsave_Click:
MsgBox Err.Description
Resume Exit_cmdsave_Click
End If
End If
'End If
' End If
' End If
End If
End If
End If
End If
End If
' End If
End Sub
End Function
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1
KeyCode = 0
MsgBox "f1 pressed"
Case vbKeyF10
' KeyCode = 0
MsgBox "f10 pressed"
Call SaveFunction
'براي ساير کليدها مي تواني همينجا تعريف کنيد
End Select
End Sub