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 / Programming / December 2007

Tip: Looking for answers? Try searching our database.

Ok try agian. User form LastRow

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jennifer - 25 Apr 2005 04:13 GMT
Hi Hi Hi-
Ok, I am still trying to get my user form to work. Since the help earlier
just confused me even more I decided to start with a clean workbook and start
from scratch.
I have a user form that I want the user to be able to enter data or look at
data already in the database using <First> <Last><Next> and <Previous>
buttons and it show the record. Soooooo the following is as far as I have
gotten and have hit a wall. The cbofirst button works but I can't seem to get
the cboprev button to work. Thank you, Jennfier

Remember I am very green at this I need a lot of hand holding!

Private Sub cmdFirst_Click()
RowNumber.Text = "2"
End Sub

Private Sub cmdPrev_Click()

Dim r As Long

If IsNumeric(RowNumber.Text) Then
   r = CLng(RowNumber.Text)
   
   r = r - 1
   If r > 1 And r <= LastRow Then
       RowNumber.Text = FormatNumber(r, 0)
   
   End If
End If
End Sub

Private Sub cmdSave_Click()

End Sub

Private Sub RowNumber_Change()
GetData
End Sub
Private Sub DisableSave()
cmdSave.Enabled = False
cmdClose.Enabled = False
End Sub

Though daily learning, I LOVE EXCEL!
Jennifer
Patrick Molloy - 25 Apr 2005 07:30 GMT
make the following the code behind the userform. I assume that the active
sheet has data in column A starting at row 2.
I also assume the form has four command buttons ( cmdFirst, cmdPrev,
cmdNext, cmdLast) as one textbox called RowNumber.
I called a long variable LastRow, and the use the form's Initialise event to
get this from the table and set the RowNumber textbox to the first row.

Option Explicit
Private LastRow As Long
Private Sub UserForm_Initialize()
   LastRow = Range("A2").End(xlDown).Row
   RowNumber = 2
End Sub

Private Sub cmdFirst_Click()
   RowNumber.Text = "2"
   GetData
End Sub

Private Sub cmdPrev_Click()
   Dim r As Long
   If IsNumeric(RowNumber.Text) Then
       r = CLng(RowNumber.Text)
       r = r - 1
       If r > 1 And r <= LastRow Then
           RowNumber.Text = FormatNumber(r, 0)
       End If
   End If
   GetData
End Sub
Private Sub cmdNext_Click()
   Dim r As Long
       If IsNumeric(RowNumber.Text) Then
       r = RowNumber
       If r < LastRow Then
           r = r + 1
       Else
           r = LastRow
       End If
   RowNumber = r
   GetData
   End If
End Sub
Private Sub cmdLast_Click()
   RowNumber = LastRow
   GetData
End Sub
Private Sub cmdSave_Click()
   
End Sub

Private Sub RowNumber_Change()
   GetData
End Sub
Private Sub DisableSave()
   cmdSave.Enabled = False
   cmdClose.Enabled = False
End Sub
Private Function GetData()
   ' some code here to populate controls
End Function

> Hi Hi Hi-
> Ok, I am still trying to get my user form to work. Since the help earlier
[quoted text clipped - 41 lines]
> Though daily learning, I LOVE EXCEL!
> Jennifer
Jennifer - 25 Apr 2005 08:06 GMT
Patrick,
As usual your awesome. It works like a charm! To bad you weren't around 8hrs
ago. Good learning experiences I guess. Thank you!

> make the following the code behind the userform. I assume that the active
> sheet has data in column A starting at row 2.
[quoted text clipped - 103 lines]
> > Though daily learning, I LOVE EXCEL!
> > Jennifer
Patrick Molloy - 25 Apr 2005 08:24 GMT
shucks,  blush

;)

> Patrick,
> As usual your awesome. It works like a charm! To bad you weren't around 8hrs
[quoted text clipped - 107 lines]
> > > Though daily learning, I LOVE EXCEL!
> > > Jennifer
Charlie - 25 Dec 2007 01:15 GMT
This is VERY helpful to me, also.  One more thing I can't quite figured out:  
I Column A contains Names, and I have a textbox on the form called
textboxName, what code would I add to have the name displayed in this textbox
this pertains to the chosen row number?
thank you,
Slowly Learning

> shucks,  blush
>
[quoted text clipped - 111 lines]
> > > > Though daily learning, I LOVE EXCEL!
> > > > Jennifer
carlo - 25 Dec 2007 01:35 GMT
Hi Charlie

you could add following code:

me.textboxName.value = worksheets("myWorksheet").cells(RowNumber,
1).value

hth

Carlo

On Dec 25, 10:15 am, Charlie <Char...@discussions.microsoft.com>
wrote:
> This is VERY helpful to me, also.  One more thing I can't quite figured out:  
> I Column A contains Names, and I have a textbox on the form called
[quoted text clipped - 120 lines]
>
> - Show quoted text -
Charlie - 25 Dec 2007 01:46 GMT
GREAT!  I came up with something, but it's way cumbersome (as usual), and
I'll need to apply this code to numerous textboxes..
...have another question, but maybe I'm suposed to start a new thread?  
....so will do so.
thanks.
 
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.