By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,738 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,738 IT Pros & Developers. It's quick & easy.

Code: Private Sub help

P: n/a
The following code (VB6) automatically sets ticks or null values for
Check Boxes: 'Pass' and/or 'Resit', depending on the data entered in
the 'ModuleID' and 'Mark' Text Boxes.

'ModuleID' is a Text Box which records the module number of the exam.
Module 1 has a pass mark of 27 and modules 2-7 have a pass mark of 24.

Private Sub Mark_AfterUpdate()
Dim intPassMark As Integer

If Me.[ModuleID] = 1 Then
intPassMark = 27
Else
intPassMark = 24
End If

If IsNull(Me.Mark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.Mark >= intPassMark)
Me.Resit = Not Me.Pass
End If

End Sub

This works fine:-)

I also have a control 'IVMark', (Text Box which is used to record
secondary marking results), and need it to override the above code if
marks are found to be below the pass mark.

Can you help?
Nov 12 '05 #1
Share this Question
Share on Google+
4 Replies

P: n/a
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Your question appears to be "How can I have the results of TextBox
IVMark take precedence over the results of TextBox Mark?" Correct?

One method would be to create a module variable that will be set/reset
by TextBox IVMark. E.g.:

Declaration section:

Dim m_blnIVMark_Set As Boolean

- -------

Private Sub IVMark_AfterUpdate()

m_blnIVMark_Set = Not IsNull(Me!IVMark)

... other code that sets Pass/Re-sit values ...

End Sub

Private Sub Mark_AfterUpdate()

If m_blnIVMark_Set Then Exit Sub

... etc. ...

End Sub
Another method: in the IVMark AfterUpdate event you could disable the
TextBox Mark after a valid datum has been entered into the IVMark
TextBox:

If Not IsNull(Me!IVMark) Then
Me!Mark = "" ' Clear the value first
Me!Mark.Enabled = False

' ... continue by setting the Pass/Re-sit values ...

End If

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP+ixtIechKqOuFEgEQJ/KACgyBs9BartRH1JUlEqTR+RQsiVg3QAoIlf
RoAO/j/wrhYdJkAFf2RpgZaf
=pNzT
-----END PGP SIGNATURE-----
Terry wrote:
The following code (VB6) automatically sets ticks or null values for
Check Boxes: 'Pass' and/or 'Resit', depending on the data entered in
the 'ModuleID' and 'Mark' Text Boxes.

'ModuleID' is a Text Box which records the module number of the exam.
Module 1 has a pass mark of 27 and modules 2-7 have a pass mark of 24.

Private Sub Mark_AfterUpdate()
Dim intPassMark As Integer

If Me.[ModuleID] = 1 Then
intPassMark = 27
Else
intPassMark = 24
End If

If IsNull(Me.Mark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.Mark >= intPassMark)
Me.Resit = Not Me.Pass
End If

End Sub

This works fine:-)

I also have a control 'IVMark', (Text Box which is used to record
secondary marking results), and need it to override the above code if
marks are found to be below the pass mark.

Can you help?


Nov 12 '05 #2

P: n/a
Yes that's correct. I altered my code as follows but this doesn't make
the results of TextBox IVMark take precedence over the results of
TextBox Mark. BTW why the exclamation mark after 'Me' and not a dot?

Option Compare Database

Dim m_blnIVMark_Set As Boolean
Private Sub IVMark_AfterUpdate()

m_blnIVMark_Set = Not IsNull(Me!IVMark)
Dim intPassMark As Integer
If Me.[ModuleID] = 1 Then
intPassMark = 27
Else
intPassMark = 24
End If
If IsNull(Me.IVMark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.IVMark >= intPassMark)
Me.Resit = Not Me.Pass
End If
End Sub
Private Sub Mark_AfterUpdate()
Dim intPassMark As Integer
If m_blnIVMark_Set Then Exit Sub

If Me.[ModuleID] = 1 Then
intPassMark = 27
Else
intPassMark = 24
End If
If IsNull(Me.Mark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.Mark >= intPassMark)
Me.Resit = Not Me.Pass
End If
End Sub

Terry
Hash: SHA1

Your question appears to be "How can I have the results of TextBox
IVMark take precedence over the results of TextBox Mark?" Correct?

One method would be to create a module variable that will be set/reset
by TextBox IVMark. E.g.:

Declaration section:

Dim m_blnIVMark_Set As Boolean

- -------

Private Sub IVMark_AfterUpdate()

m_blnIVMark_Set = Not IsNull(Me!IVMark)

... other code that sets Pass/Re-sit values ...

End Sub

Private Sub Mark_AfterUpdate()

If m_blnIVMark_Set Then Exit Sub

... etc. ...

End Sub
Another method: in the IVMark AfterUpdate event you could disable the
TextBox Mark after a valid datum has been entered into the IVMark
TextBox:

If Not IsNull(Me!IVMark) Then
Me!Mark = "" ' Clear the value first
Me!Mark.Enabled = False

' ... continue by setting the Pass/Re-sit values ...

End If

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP+ixtIechKqOuFEgEQJ/KACgyBs9BartRH1JUlEqTR+RQsiVg3QAoIlf
RoAO/j/wrhYdJkAFf2RpgZaf
=pNzT
-----END PGP SIGNATURE-----
Terry wrote:
The following code (VB6) automatically sets ticks or null values for
Check Boxes: 'Pass' and/or 'Resit', depending on the data entered in
the 'ModuleID' and 'Mark' Text Boxes.

'ModuleID' is a Text Box which records the module number of the exam.
Module 1 has a pass mark of 27 and modules 2-7 have a pass mark of 24.

Private Sub Mark_AfterUpdate()
Dim intPassMark As Integer

If Me.[ModuleID] = 1 Then
intPassMark = 27
Else
intPassMark = 24
End If

If IsNull(Me.Mark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.Mark >= intPassMark)
Me.Resit = Not Me.Pass
End If

End Sub

This works fine:-)

I also have a control 'IVMark', (Text Box which is used to record
secondary marking results), and need it to override the above code if
marks are found to be below the pass mark.

Can you help?

Nov 12 '05 #3

P: n/a
MGF Wrote:Your question appears to be "How can I have the results of
TextBox
IVMark take precedence over the results of TextBox Mark?" Correct?

One method would be to create a module variable that will be set/reset
by TextBox IVMark. E.g.:


Code now works great:-)
I had forgotten to set the event procedure for the IVMark TextBox
AfterUpdate but I got there evantually.

Thanks for your help.

For anyone interested this is a full copy of the code:-

Option Compare Database
Dim m_blnIVMark_Set As Boolean

Private Sub IVMark_AfterUpdate()
m_blnIVMark_Set = Not IsNull(Me!IVMark)
Dim intPassMark As Integer
If Me.[ModuleID] = 1 Then
intPassMark = 27
Else
intPassMark = 24
End If
If IsNull(Me.IVMark) Then
Me.Pass = (Me.Mark >= intPassMark)
Me.Resit = Not Me.Pass
Else
Me.Pass = (Me.IVMark >= intPassMark)
Me.Resit = Not Me.Pass
End If
End Sub
Private Sub Mark_AfterUpdate()
Dim intPassMark As Integer
If m_blnIVMark_Set Then Exit Sub

If Me.[ModuleID] = 1 Then
intPassMark = 27
Else
intPassMark = 24
End If
If IsNull(Me.Mark) Then
Me.Pass = False
Me.Resit = False
Else
Me.Pass = (Me.Mark >= intPassMark)
Me.Resit = Not Me.Pass
End If
End Sub

Terry
Nov 12 '05 #4

P: n/a
Terry wrote:
.... BTW why the exclamation mark after 'Me' and not a dot?


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

The exclamation point (!) indicates a collection. The default
collection for forms is the Controls collection. Referring to a
control on a form is Me!ControlName.

The period (.) indicates a property. Unfortunately (or fortunately,
depending on your POV) either punctuation mark can be used to refer to
a control.

This controversy has undergone many iterations on this newsgroup -
just search Google.Groups (if you can get the search engine to
recognize ! and . as valid characters).

HTH,

MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBP+tzDIechKqOuFEgEQIdrACfWID5msxL9x7APzJ7EIkJ12 stuvgAn3lc
FRAQMfBfarwXPU2RbP9FtUFf
=xExY
-----END PGP SIGNATURE-----

Nov 12 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.