Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2007

Tip: Looking for answers? Try searching our database.

Need Code Snippet Help

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Angyl - 12 Nov 2007 19:25 GMT
This isn't working quite right.  I want the code to check which box is
checked and put one thing in the cell, and if neither of them are cheked to
put nothing in, but I'm always just getting the second choice (6789)
irregardless of the checkbox status.

Pls help.

With tblTarget
If Check1.Checked = True Then
   .Cell(1, 1).Range.Text = "12345"
   If Check2.Checked = True Then
   .Cell(1, 1).Range.Text = "6789"
   End If
End With
larrysulky@gmail.com - 12 Nov 2007 21:49 GMT
---SNIP---

> With tblTarget
> If Check1.Checked = True Then
[quoted text clipped - 3 lines]
>     End If
> End With

I'm not clear on your intended logic. You are missing an End If
statement somewhere, presumably immediately after the first End If. In
that case, what you have coded here will only check Check2 if Check1
was checked. It appears that the logic you want to achieve is this:

a) If Check1 and Check2 are both checked, use value "6789")
b) if Check1 only is checked, use value "12345"
c) if neither Check1 nor Check2 is checked, or if Check2 only is
checked, do not use any value (for which case you should probably
initialise the value to nil).

Correct?
NZ VBA Developer - 12 Nov 2007 23:36 GMT
Just change

If Check2.Checked = True Then

to

ElseIf Check2.Checked = True Then

and just to be safe add another line before the "End If"

Else: .Cell(1, 1).Range.Text =""

That should fix it.
Signature

Cheers!
The Kiwi Koder

> ---SNIP---
> >
[quoted text clipped - 18 lines]
>
> Correct?
Angyl - 13 Nov 2007 15:58 GMT
Thanks!!

> Just change
>
[quoted text clipped - 32 lines]
> >
> > Correct?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.