Quote:
Originally Posted by firozfasilan
please explain the following code to me
I want to know in detail would you help me?
Public Function MnuUpload()
Screen.MousePointer = 11
mI = ExecuteSQL("DELETE FROM SCMnuElements WHERE IDModu='" & Mid(App.Title, 1, 2) & "'")
Set aRS = GetRSLoaded("SCMnuElements")
Dim xStri As String
Dim FormCtrl As Control
For Each FormCtrl In FrmXX
With FormCtrl
If TypeOf FormCtrl Is Menu Then
If Len(FormCtrl.Name) = 13 Then
vStri = FormCtrl.Caption
xStri = ""
For mI = 1 To Len(vStri)
If Not Mid(vStri, mI, 1) = "&" Then xStri = xStri & Mid(vStri, mI, 1)
Next
vInti = pfGetNextID("SCMnuElements", "RecNbr", "")
aRS.AddNew
aRS![RecNbr] = vInti
aRS![IDModu] = UCase(Mid(App.Title, 1, 2))
aRS![NameMo] = App.FileDescription
aRS![IDMenu] = FormCtrl.Name
aRS![NameMn] = xStri
aRS.Update
End If
End If
End With
Next
Screen.MousePointer = 0
MsgBox "Menu Elements Up-Load is Done !", vbInformation, App.FileDescription
End Function
1. set screen mouse pointer to HourGlass
2 Delete Record from SCMnuElements WHERE IDModu='" & Mid(App.Title, 1, 2) & "'
3 loding records in aRs
For Each FormCtrl In FrmXX
With FormCtrl
If TypeOf FormCtrl Is Menu Then
If Len(FormCtrl.Name) = 13 Then
vStri = FormCtrl.Caption
xStri = ""
For mI = 1 To Len(vStri)
If Not Mid(vStri, mI, 1) = "&" Then xStri = xStri & Mid(vStri, mI, 1)
Next
vInti = pfGetNextID("SCMnuElements", "RecNbr", "")
aRS.AddNew
aRS![RecNbr] = vInti
aRS![IDModu] = UCase(Mid(App.Title, 1, 2))
aRS![NameMo] = App.FileDescription
aRS![IDMenu] = FormCtrl.Name
aRS![NameMn] = xStri
aRS.Update
End If
End If
End With
Next
4 get all controls in Form and check if the tontrol is Menu or Not a menu
If menu then checking the name of that control name string length is 13
if yes then assigen vStri = FormCtrl.Caption
For mI = 1 To Len(vStri)
If Not Mid(vStri, mI, 1) = "&" Then xStri = xStri & Mid(vStri, mI, 1)
Next
5 replacing null if the string contain '&'
this is not good, (beter use Replace(trim(vStri),"&",""))
vInti = pfGetNextID("SCMnuElements", "RecNbr", "")
6 Geting Next Id of the Record
aRS.AddNew
aRS![RecNbr] = vInti
aRS![IDModu] = UCase(Mid(App.Title, 1, 2))
aRS![NameMo] = App.FileDescription
aRS![IDMenu] = FormCtrl.Name
aRS![NameMn] = xStri
aRS.Update
7 Adding New record,
with new id,
UCase(Mid(App.Title, 1, 2))
8 Converting Uppercase of Application first two Character
App.FileDescription
9 geting Application File Description.
FormCtrl.Name
10 Form Name
aRS.Update
11 Updating Record
this will give Error Because you are adding (aRS.AddNew) New Record but finaly you are Updating... Use (aRS.Save)
Screen.MousePointer = 0
MsgBox "Menu Elements Up-Load is Done !", vbInformation, App.FileDescription
12 set mousepointer to default arrow,
Popup Information (!) msgbox
OOOOOOOOOOOOOOooooooooooooooooooK..........