-1-
-2-
Option Compare Database
Private Sub Command12_Click()
Dim x As Integer
Dim y As Integer
Dim r As Integer
x = Me.Text4.Value
y = Me.Text6.Value
r = x + y
Me.Text8.Value = r
End Sub
Private Sub Command13_Click()
Back Color = 65280
End Sub
Private Sub Command14_Click()
MsgBox "This is a message box in VBA."
End Sub
Private Sub Command15_Click()
Call Command14_Click
End Sub
Sub ShowMessage3(strMessage, strUserName)
MsgBox strUserName & ", your message is: " & strMessage
End Sub
Private Sub Command16_Click()
Call ShowMessage3("Keep on learning.", "John")
End Sub
Function addTwoNumbers()
Dim num1 As Integer
Dim num2 As Integer
num1 = 3
num2 = 2
addTwoNumbers = num1 + num2
End Function
Private Sub Command17_Click()
End Sub
Private Sub Command18_Click()
' variable declaration
Dim strFullName As String
Dim dateOfBirth As Date
Dim intAge As Integer
Dim intmMo As Integer
Dim intdy As Integer
' assign values to variables
strFullName = "John Smith"
'dateOfBirth = #1/3/1967#
dateOfBirth = Me.START_DATE.Value
' calculate age
intAge = Year(Now()) - Year(dateOfBirth)
'intmMo = Month(Now()) - Month(dateOfBirth)
'intdy = Day(Now()) - Day(dateOfBirth)
' print results
MsgBox (strFullName & " is " & intAge & " years old ")
End Sub
Private Sub Command2_Click()
Dim stx As String
stx = "hello here in vba "
Text12.Value = " hello "
Text0.Value = stx
MsgBox ("Hello World ....")
End Sub
Private Sub Command22_Click()
Dim question As String
Dim bts As Integer
Dim myTitle As String
Dim myButton As Integer
question = "Do you want to preview the report now?"
bts = vbYesNoCancel + vbQuestion + vbDefaultButton1
myTitle = "Report"
myButton = MsgBox(prompt:=question, buttons:=bts, Title:=myTitle)
Select Case myButton
Case 6
DoCmd.OpenReport "Sales by Year", acPreview
Case 7
MsgBox "You can review the report later."
Case Else
MsgBox "You pressed Cancel."
End Select
End Sub
Private Sub Command23_Click()
Dim weeks As String
On Error GoTo VeryEnd
weeks = InputBox("How many weeks are in a year:", "Quiz")
If weeks <> 52 Then MsgBox "Try Again" ' SimpleIfThen2
If weeks = 52 Then MsgBox "Congratulations!"
VeryEnd:
End Sub
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Private Sub Command24_Click()
Dim x As Integer, YesNo As Boolean
x = 2
If x = 2 Then
YesNo = True
Else
YesNo = False
End If
Check25 = YesNo
End Sub
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Private Sub Command24_Click()1 And x > 0) Then
If Not x <> 2 Then
YesNo = True
Else
YesNo = False
End If
Check25 = YesNo
End Sub
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
Private Sub Command24_Click()
Dim x As Integer, YesNo As Boolean
x = 2
' If (x + 2) \ 4 = 1 Then
' If x <> 2 Or (x > 1 And x > 0) Then
If Not x <> 2 Then
YesNo = True
Else
YesNo = False
End If
Check25 = YesNo
End Sub
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' ==Using Nested If Statements==
If x > 9 Then
If x < 20 Then
MsgBox "x is between 10 and 19."
Else
If x < 30 Then
MsgBox "x is between 20 and 29"
Else
If x < 40 Then
MsgBox "x is between 30 and 39"
End If
End If
End If
Else
MsgBox "x is less than 9"
End If
' '==Using Select Case Statements==
Select Case x
Case Is < 9
MsgBox "x is less than 9"
Case 10 To 19
MsgBox "x is between 10 and 19."
Case 20, 21, 22, 23, 24, 25, 26, 27, 28, 29
MsgBox "x is between 20 and 29."
Case Else
MsgBox "x is unknown."
End Select
' '==Alternative Select Case Statement (Like If Statement==
Select Case True
Case x < 9
MsgBox "x is less than 9."
Case x > 0 And x < 20
MsgBox "x is between 9 and 19."
Case x >= 20 And x <= 29
MsgBox "x is between 20 and 29."
Case Else
MsgBox "x is unknown."
End Select
End Sub
مسلسل | اسم الملف | المدة ب الدقيقة | لينك |
---|---|---|---|
1 | 001 MS Access VBA Grouping Code , Variables And Data Types | 18 | https://youtu.be/iT1bFbliG5E |
2 | 002 MS Access VBA – Writing First Code 2 programs in one form | 16 | https://youtu.be/h-jXH_kcE4c |
3 | 003 MS Access VBA – Writing First 2 programs | 14 | https://youtu.be/Z36lpESNk8k |
4 | 004 MS Access VBA –Decision Making if then | 24 | https://youtu.be/phtKVh-QQ9w |
5 | 005 MS Access VBA –Decision Making if then elsif nested if | 16 | https://youtu.be/IRYnGtcoJKo |
6 | 006 MS Access VBA –Decision Making Select Case | 20 | https://youtu.be/32OckF0Zv6I |
7 | 007 MS Access VBA –Decision Making prorams part1 | 14 | https://youtu.be/M15BE4uHWeY |
110 | قائمة ملفات تعلم اكسيس المستوى الاول MS Access 380 min | https://www.youtube.com/playlist?list=PLMmy9Ec9B98wxI2RWVrjjtyV2knTFoR1t |
-3-
-4-