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 / May 2005

Tip: Looking for answers? Try searching our database.

First Try at Creating a User Form

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jack Gillis - 31 May 2005 01:18 GMT
I have exhausted my search abilities to find an answer to what should be
a simple question.

I created a user form that pretty much duplicates the built in Data
Form.  The major difference is that it does not contain all of the
fields in the data base -- just a few of them and it doesn't have all of
the controls only a Next and Previous control as well a Close.

The form is just what I want but I can't figure out how to get it to
display the values of the fields when I open it.  That is the first
problem..   I want it, like the built in form, to show the values of
fields for each record as I move up and down through the database by
putting a Next and Previous control on the form.

Can someone get me started in the right direction?

Thank you very much.
Harald Staff - 31 May 2005 07:55 GMT
Hi

Try this -all userform code:

'******************* top of module**************
Option Explicit

Dim R As Long

Private Sub UserForm_Initialize()
R = ActiveCell.Row
Call FillControls
End Sub

Sub FillControls()
TextBox1.Text = Sheets(1).Cells(R, 1).Text
TextBox2.Text = Sheets(1).Cells(R, 2).Text
ComboBox1.Text = Sheets(1).Cells(R, 3).Value
End Sub

Sub WriteToSheet()
Sheets(1).Cells(R, 1).Value = TextBox1.Text
Sheets(1).Cells(R, 2).Value = TextBox2.Text
Sheets(1).Cells(R, 3).Value = ComboBox1.Text
End Sub
Private Sub CommandButton1_Click()
Call WriteToSheet
If R > 1 Then R = R - 1
Call FillControls
End Sub

Private Sub CommandButton2_Click()
Call WriteToSheet
R = R + 1
Call FillControls
End Sub

HTH. Best wishes Harald

> I have exhausted my search abilities to find an answer to what should be
> a simple question.
[quoted text clipped - 13 lines]
>
> Thank you very much.
Jack Gillis - 31 May 2005 09:44 GMT
Thank you very much Harald.

That seems straightforward enough.  I can see where I went wrong.  I
thought the individual cells could be referred to by their Row and the
column heading of the database.  I suppose the same procedure could be
used in reverse to change the cell values from the form if I ever chose
to do so.

Thanks again.

> Hi
>
[quoted text clipped - 54 lines]
>>
>> Thank you very much.
Harald Staff - 31 May 2005 13:14 GMT
> Thank you very much Harald.
> That seems straightforward enough.  I can see where I went wrong.

Glad to hear that. Thanks for the feedback.

> I suppose the same procedure could be
> used in reverse to change the cell values from the form if I ever chose
> to do so.

The provided "WriteToSheet" does just that, the reverse of "FillControls".

Best wishes Harald
 
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.