VBA Codes not working, Please Help

F

FA

I have a problem that my code is not working i dont know what i am
doing wrong? can someone help me out please;
I have a form called frmSystem---- Control source = dbo_SYS_INO
On that form i have four controls
textbox -- SYS_NME--- Bound to Field SYS_NME in dbo_SYS_INFO
textbox-- SYS_CODE-- Bound to field SYS_CODE in dbo_SYS_INFO
textbox-- CODE-- Unbound -- Control Source = GetAbbrevs(Me.SYS_NME) &
"V"
Where the GetAbbrevs is a Function
Public Function GetAbbrevs(sText As String) As String
Dim sTmp As String
sText = Trim(sText)
Do While InStr(1, sText, " ") > 0
sTmp = sTmp & Left(sText, 1)
sText = Mid(sText, InStr(1, sText, " ") + 1)
Loop
GetAbbrevs = sTmp & Left(sText, 1)
End Function

Also i have a command button --- Command566
In the OnClick event of the command button
i have something like this
Private Sub Command566_Click()
If Me.NewRecord Then
Dim strSysNumber
Dim varResult As Variant
strSysNumber = "SYS_CODE Like """ & Me.CODE & "*"""
varResult = DMax("SYS_CODE", "dbo_SYS_INFO",
strSysNumber)
If IsNull(varResult) Then
Me.SYS_CODE = Me.CODE & "01"
Else
Me.SYS_CODE = Me.CODE &
Format(Val(Right(varResult, 2)) + 1, "00")
End If
End If
When i click the command button nothing happens. textbox CODE is
showing me the abbreviated SYS_NME so my command button codes should
read the data in textbox CODE and compare it with SYS_CODE in the table
and if exist add 1 to it.

No compile error, it just nothing happen when i click the command
button.
Please help!!!
Moe
 
W

Wayne Morgan

Nothing just pops out at me, so a few questions.

1) Did you set the On Click event in the buttons Property sheet to [Event
Procedure]?

2) You say it does nothing when you click the button, have you tried
stepping through the code to see what it is doing? Have you verified that
the code either does or doesn't even run?

3) You start the code off with the statement "If Me.NewRecord Then", this
will only run if you're at a new record. If you are, then what would be the
value for Me.Code?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top