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 / Excel / New Users / July 2006

Tip: Looking for answers? Try searching our database.

More help needed re form & msgbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Pam Field - 22 Jul 2006 07:34 GMT
Thanks to those who helped earlier.  I have two more questions (I hope
that's all).  Once again my code so far is:

Private Sub cmdRemChild_Click()
   Dim myCell As Range
   Dim ChosenName As String
   Dim NameFound As Boolean
   Dim YesNo As Integer

   ChosenName = cboChildName.Text
   Sheets("Child Records").Select

   NameFound = False
   For Each myCell In Range("Name_of_Child")
       If myCell.Value = ChosenName Then
           myCell.Select
           NameFound = True
           Unload Me
           Exit For
       End If
   Next myCell

   If NameFound = False Then
       MsgBox "Name not entered or not Found!"
       cboChildName.SetFocus
   End If

   YesNo = MsgBox("Are you sure you want to remove this child?", vbYesNo +
vbExclamation, "Caution")

   Select Case YesNo
        Case vbYes
        Selection.Delete Shift:=xlUp
        Range("A6").Select
   Case vbNo
         frmRemChild.Show
   End Select

End Sub
________________________

If I click on the cmdRemChild button without choosing a name I get msgBox
"Name not entered ......." - I click on no for this and it goes straight to
msgBox "Are you sure .........".  What I want to happen if I don't choose a
name is for it to SetFocus on cboChildName. (It does this if I click on the
no from the msgBox "Are you sure .... etc".

Last problem (I hope) is that I want it to delete the entire row not just
the cell the name is in.  Can someone please explain how I do this?

Thanks again so much for your help so far.

Regards
Pam
JON JON - 22 Jul 2006 08:08 GMT
> Thanks to those who helped earlier.  I have two more questions (I hope
> that's all).  Once again my code so far is:
[quoted text clipped - 50 lines]
> Regards
> Pam

Try this:

Private Sub cmdRemChild_Click()
>    Dim myCell As Range
>    Dim ChosenName As String
>    Dim NameFound As Boolean
>    Dim YesNo As Integer
>
>    ChosenName = cboChildName.Text

   If Len(ChosenName) = 0 then
       cboChildName.SetFocus
       Exit Sub
   End if
>    Sheets("Child Records").Select
>
[quoted text clipped - 25 lines]
>
> End Sub
Pam Field - 22 Jul 2006 08:43 GMT
If Len(ChosenName) = 0 then
       cboChildName.SetFocus
       Exit Sub
   End if

Thanks so much.  This worked even though I will never know why :-)

Now to beg for help with the absolute last question.  How do I delete the
whole row instead of just the cell the name is in?
Dave Peterson - 22 Jul 2006 13:05 GMT
Selection.Delete Shift:=xlUp
becomes
Selection.entirerow.delete

>    If Len(ChosenName) = 0 then
>         cboChildName.SetFocus
[quoted text clipped - 5 lines]
> Now to beg for help with the absolute last question.  How do I delete the
> whole row instead of just the cell the name is in?

Signature

Dave Peterson

 
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.