In the code, "S" is declared as a Variant, not a Long Integer. You must explicitly declare S as a Long like this:
Dim S As Long, Serial As Long, ...
------------
Also, you have
strSQL As String and
sSQL As String
but only use sSQL
Doesn't hurt, but it is an unused variable..
------------
I had trouble following the flow, so I re-wrote the function. Using IF()'s is fine.
See if this helps you find your problem.
Code:
Public Function CheckVolumeSerialNumber1()
Dim S, Serial As Long, VName As String, FSName As String, strSQL As String
Dim SVNnumber As String
Dim sSQL As String
VName = String$(255, Chr$(0))
FSName = String$(255, Chr$(0))
GetVolumeInformation "C:\", VName, 255, Serial, 0, 0, FSName, 255
VName = Left$(VName, InStr(1, VName, Chr$(0)) - 1)
FSName = Left$(FSName, InStr(1, FSName, Chr$(0)) - 1)
Serial = Replace(Trim(Str$(Serial)), "-", "")
' ?????? ????????? ??????? ??? ?????????? ??? ?????? ??? ?? S
S = Serial
'Wipe the existing data from tblSVN
sSQL = "DELETE * FROM tblSVN;"
CurrentDb.Execute sSQL, dbFailOnError
If S = 2032771935 Then
If Forms!MasterForm.FirstInstallation = True Then
MsgBox "CheckVolumeSerialNumber1 - Welcome adninistrator", vbExclamation, "Administrator Login"
End If
If Forms!MasterForm.TrialMode = True Then
MsgBox "CheckVolumeSerialNumber1 - Welcome adninistrator", vbExclamation, "Administrator Login"
End If
'common to the previous IF() functions
Forms!MasterForm.SVNA = S
Forms!MasterForm.Pc3 = True
Forms!MasterForm.Refresh
DoCmd.OpenForm "frmStartupScreen"
Else ' S <> 2032771935
'common to the following IF() statements
strSQL = "INSERT INTO tblSVN (SvnNumber,DateAdded) VALUES(" & _
Serial & ", #" & Format(Now(), "m/d/yyyy mm:ss") & "#)"
CurrentDb.Execute (strSQL)
Forms!frmSVN.Refresh
If Forms!MasterForm.FirstInstallation = True Then
MsgBox "???????? ???????????? ?? ????????? ??? ???????? ", vbInformation, "???? ???????"
DoCmd.OpenForm "frmAddOwner", acNormal
End If
If Forms!MasterForm.TrialMode = True Then
Forms!MasterForm.Refresh
ExistSN
End If
End If
End Function
Have you set a break point and stepped through the code?
BTW, in the message boxes, the first "administator" is misspelled. You have "Welcome adninistrator"