Sub DbOpen()
Set CurDB = OpenDatabase(IIf(Right(App.Path, 1) = "\", App.Path & "namelist.mdb", App.Path & "\namelist.mdb"))
End Sub
Function Path() As String
Path = IIf(Right(App.Path, 1) = "\", App.Path, App.Path & "\")
End Function
Sub ErrorHandler(Err%, Module$, Action$)
'Error Handling Routine
Dim FNum
Dim FName
FNum = FreeFile
FName = Path() & App.EXEName & ".err"
Open FName For Append As FNum
Print #FNum, " Date/Time : " & Format(Now, "dd/mm/yyyy hh:nn:ss")
Print #FNum, " Module : " & Module
Print #FNum, " Action : " & Action
Print #FNum, " Err Code : " & Err
Print #FNum, " Err Msg : " & Error(Err)
Print #FNum, " " & String$(76, "-")
Close
MsgBox "System encountered an unexpected error !" _
& "Please contact the Technical Personnel.", vbCritical + vbOKOnly
Screen.MousePointer = vbNormal
End Sub
假设你的form上有6个textbox, from text1 to text6, users are required to enter values of name, age, address, hp number, workphone number and homephone number into the textboxes.另外做一个combo box, 里面的list加上 “handphone“, “workphone“, “homephone“,另外加一个command button, name it cmdOk.
Dim Entryvalue As Single
If Combo1.Text = "Handphone" Then
Entryvalue = Val(Text4.Text)
ElseIf Combo1.Text = "Workphone" Then
Entryvalue = Val(Text5.Text)
ElseIf Combo1.Text = "HomePhone" Then
Entryvalue = Val(Text6.Text)
End If