What is the code you have now?
This has invalid syntax
Code:
Forms!Form![txt_unlockCode]
(has the word FORM and missing the form name)
The reference to the control "txt_unlockCode" on the form "frmMembers" from a standard module should be
Code:
Forms!frmMembers.txt_unlockCode
If you want to leave "Sub verifyserial()" in a standard module, the code would be
Code:
Option Compare Database
Option Explicit
Public Sub verifyserial()
Dim str3 As String
Dim i As Integer
Dim txt_serial As String
Dim PASS(6) As String
Randomize
str3 = Int(Rnd(7) * 1000000)
Forms!frmMembers.txt_serial = str3
Debug.Print str3
Debug.Print Forms!frmMembers.txt_unlockCode
Forms!frmMembers.txt_unlockCode = "DEMOH"
MsgBox Forms!frmMembers.txt_unlockCode
MsgBox str3
Debug.Print Forms!frmMembers.txt_unlockCode
'CREATE UNLOCK CODE in process
End Sub
If you move the routine to the form module, the the code would be
Code:
Option Compare Database
Option Explicit
Private Sub Form_Load()
verifyserial
End Sub
Public Sub verifyserial()
Dim str3 As String
Dim i As Integer
Dim txt_serial As String
Dim PASS(6) As String
Randomize
str3 = Int(Rnd(7) * 1000000)
Me.txt_serial = str3
Debug.Print str3
Debug.Print Me.txt_unlockCode
Me.txt_unlockCode = "DEMOH"
MsgBox Me.txt_unlockCode
MsgBox str3
Debug.Print Me.txt_unlockCode
'CREATE UNLOCK CODE in process
End Sub
Pick either a standard module OR form module - code cannot be in both places at the same time with the same name.
Note: this is just restating what June7 said...........