Re: Skip a line of code and continue
- From: "tina" <nospam@xxxxxxxxxxx>
- Date: Fri, 19 Jun 2009 03:52:37 GMT
to answer your last question, which my previous post didnt: i'm sorry, i
don't know of any courses, online or offline, that cover that particular
topic. you might try googling. if that brings no joy, you might post the
question to the newsgroup microsoft.public.access.modulesdaovba
and see if anybody else has suggestions.
but honestly, i don't think you need a whole course, Bob. seems like this is
one of those "lightbulb" concepts, once the light goes on for you, it'll
make complete sense. i bet if you could sit with somebody for 15 minutes of
demonstration/explanation, you'd get it, and be off and running. i worked my
way up through Access to my current level (nowhere near the top, yet!) from
dirt bottom, with no newgroup or other online resources to help me until i
had already graduated from macros to VBA. i did have the great good fortune
to find a couple local nightschool classes that taught me the basics of
relational design principles and later the very very basic basics of writing
VBA code (this was back around 1999 or 2000). and before that, i remember
reading and re-reading Access Help, and beating my head against a wall, for
two months before i finally grasped the concept of macros in Access - in one
of those lightbulb moments. so i think i can understand your frustration!
<g>
"Bob Waggoner" <BobWaggoner@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:67F6A1AF-DA77-4165-A4C3-7B46FEA7DB14@xxxxxxxxxxxxxxxx
Thanks for correcting the code and answering my question. I've been tryingto
take my VBA knowledge to the next level and it's frustrating trying tofigure
out how to handle modules. I can convert macros to functions and then"gut"
the function and rewrite it to private subs but using a function withoutoff
copying/gutting and pasting it to the form procedure events is where I'm
stuck.
Do you know of any on line course/help I can get to teach the basics of
using functions / calling functions, and etc?
Thanks again.
Bob
"tina" wrote:
well, i'm glad you posted back, Bob. first, let me fix the code - i left
code, asthe line that closes the If expression, sorry! here's the corrected
Design
Private Sub Form_BeforeUpdate(Cancel As Integer)
If isMissingData Then
Cancel = True
MsgBox "Enter the missing information in the " _
& "highlighted fields, please.", vbExclamation, _
"RECORD SUBMISSION CANCELLED"
End If
End Sub
okay, to answer your question: copy the entire function code (posted
previously) and paste it into the form's module. then, in the form's
itview, in the Properties box, click on the Event tab and find the
BeforeUpdate event. double click the white space beside the event name,
openwill fill in automatically with
[Event Procedure]
at the right is a "build" button (...); click the button and it will
asthe form module with the cursor inside the newly create event procedure,
first
Private Sub Form_BeforeUpdate(Cancel As Integer)
<cursor blinking here, at the left margin>
End Sub
where the cursor is blinking, paste in the "guts" of the code above, as
If isMissingData Then
Cancel = True
MsgBox "Enter the missing information in the " _
& "highlighted fields, please.", vbExclamation, _
"RECORD SUBMISSION CANCELLED"
End If
so that the complete procedure in your module ends up looking like the
BeforeUpdatecode i posted above. the code will run every time the form's
recordevent fires; that is, when you add a new record or edit an existing
from aand then 1) move to another record, or 2) close the form, or 3) move
helpmainform into a subform, or vice versa, or 4) explicitly save the record
from a menu bar or toolbar option or by running code - from a command
button, for instance - to save the record.
hth
"Bob Waggoner" <BobWaggoner@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:0FFD6E61-E532-49E4-99C0-50D191219543@xxxxxxxxxxxxxxxx
Tina,
Thank you for your help on this. I'm a relative novice - if you could
howme in one more thing...how do I call a function? I don't know where or
canto
place this code so that it activates at the right time.SingleForm
Thanks
Bob
"tina" wrote:
here's some code that i use to highlight required controls in a
view, when the data isn't entered, as
Private Function isMissingData() As Boolean
Dim ctl As Control
For Each ctl In Me.Controls
If ctl.Tag = "r" Then
If IsNull(ctl) Then
ctl.BackColor = yello
isMissingData = True
Else
ctl.BackColor = wite
End If
End If
Next
End Function
for each control i want to have evaluated, i enter an "r" in the Tag
property of the control. the "yello" and "wite" variables are global
variables that i use throughout my db for consistent coloring. you
wellset
directly.variables for the colors you want, or just use the number values
recordin my case, i run the code from a command button that releases the
from one dept's control to the next dept. but it would work equally
messagein
a form's BeforeUpdate event procedure, as
Private Sub Form_BeforeUpdate(Cancel As Integer)
If isMissingData Then
Cancel = True
MsgBox "Enter the missing information in the " _
& "highlighted fields, please.", vbExclamation, _
"RECORD SUBMISSION CANCELLED"
End Sub
hth
"Bob Waggoner" <BobWaggoner@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in
skippedcompletednews:6E784FBB-4A66-4E6F-82A7-857A7EEF8846@xxxxxxxxxxxxxxxx
I have a "Check Work" button a user can click to see if they've
a
record.
Can anyone show me a bit of code that simply pops up a list of
ContactPersonitems? For example: VendorCode, TypeofComment, Comment,
areare
some of the fields the program checks.
Right now, I have this code evaluating the fields to see if they
andcomplete:
DoCmd.Echo True, ""
If (IsNull(.EmployeeName)) Then
Beep
MsgBox "Advisory - Please enter the Employee Name.",
vbInformation, "You Forgot the Employee Name"
DoCmd.GoToControl "WebEmployeeName"
Exit Sub
End If
Instead of having code that notifies the user of each skipped box
user tothen
stops, I'd either like to list the skipped fields or allow the
vbQuestion,allow
the code to continue checking.
My attempt to allow the user to continue the check goes like this:
DoCmd.Echo True, ""
If (IsNull(.[EmployeeName])) Then
Dim intanswerEmployeeName As Integer
intanswerEmployeeName = MsgBox("Continue?", _
vbQuestion + vbYesNo, "Continue?")
If intanswerEmployeeName = vbYes Then
[This is the missing code....]
End If
If intanswerEmployeeName = vbNo Then
MsgBox "Advisory - Please enter Employee Name.",
"You forgot to enter the Employee Name"
DoCmd.GoToControl "EmployeeName"
Exit Sub
End If
End If
If you can help, I'd appreciate it. Thanks.
.
- References:
- Skip a line of code and continue
- From: Bob Waggoner
- Re: Skip a line of code and continue
- From: tina
- Re: Skip a line of code and continue
- From: Bob Waggoner
- Re: Skip a line of code and continue
- From: tina
- Re: Skip a line of code and continue
- From: Bob Waggoner
- Skip a line of code and continue
- Prev by Date: Re: Skip a line of code and continue
- Next by Date: Re: Contact Mgmt fields
- Previous by thread: Re: Skip a line of code and continue
- Next by thread: Re: Skip a line of code and continue
- Index(es):