UserForm problems

MrCaptain

Board Regular
Joined
Dec 5, 2006
Messages
123
Hi all,

I have been in to create a nice userform for several days now with no real success.

I keep getting code errors, have googled far and wide.

Does anyone have a fully working example code or workbook which includes text boxes comboboxes and perhaps a scrollbar? I also need the Initialise code and previous next buttons.

I must add that I have used frames to provide a colour background to the form and the form also has multpages as there are several worksheets. Its an ambitious project for me but I hope you can help.

Thanks for any help.

Vern
 

Excel Facts

How to calculate loan payments in Excel?
Use the PMT function: =PMT(5%/12,60,-25000) is for a $25,000 loan, 5% annual interest, 60 month loan.
There are plenty of working examples around.
Your requirements are awfully vague.

If you isolated one small part of the project, involving a few controls, we could give a concrete example that you could build on.

As you have found out, its not the controls that are difficult, its the interactions between them.
Is there a small, isolated, part of you problem that you could describe.
 
Upvote 0
Mick

Thank you for taking the time to reply.

Its just things that apparently work don't! I have copied some code diligently and got errors. So I tried to modify it and failed miserably, so I have posted it below c/w all mistakes

Here's the initialise code (incorrect)

Private Sub UserForm_Initialize()
Dim currentrow As Long
Dim strSheetName As String
'strSheetName = ActiveSheet.Name
Dim iRow1 As Long
Dim iRow2 As Long
Dim r As Worksheet, WS2 As Worksheet
Set r = Worksheets("Courses")
Set WS2 = Worksheets("Sessions")
currentrow = ActiveCell.Row
'UserForm = vbModeless
'*************************************
'Scroll bars Vertical and Horizontal
With SBColumns
.Min = 1
.Max = 256
.Value = ActiveWindow.ScrollColumn
.LargeChange = 25
.SmallChange = 1
End With
With SBRows
.Min = 1
.Max = 65536
.Value = ActiveWindow.ScrollRow
.LargeChange = 25
.SmallChange = 1
End With
'*********************************

Dim NameFound As Range
'fPath = r.ThisWorkbook.Path & "\"
'Worksheets("Courses").Activate
If Me.MultiPage1.Value = 0 Then Worksheets("Courses").Activate
If Me.MultiPage1.Value = 1 Then Worksheets("Bookings").Activate
If Me.MultiPage1.Value = 2 Then Worksheets("Customers").Activate
If Me.MultiPage1.Value = 3 Then Worksheets("Tutors").Activate
Me.txtCourse.SetFocus
txtiardRef.Value = r.Cells(currentrow, 1).Value
txtCourse.Text = r.Cells(currentrow, 2).Value
cboTutor.Text = r.Cells(currentrow, 3).Value
txtSessions.Value = r.Cells(currentrow, 4).Value
txtStartDate.Value = r.Cells(currentrow, 5).Value
txtEndDate.Value = r.Cells(currentrow, 6).Value
txtPlaces.Value = r.Cells(currentrow, 7).Value



End Sub


And a Next button.............


Private Sub cmdNext_Click()
Dim currentrow As Long
Dim r As Worksheet, WS2 As Worksheet
Set r = Worksheets("Courses")
Set WS2 = Worksheets("Sessions")
'ActiveSheet.UsedRange
'ActiveSheet.Row.Select
'Set r = ActiveSheet.UsedRange
currentrow = ActiveCell.Row
'This is the data entered value
txtiardRef.Value = r.Cells(currentrow, 1).Value
txtCourse.Text = r.Cells(currentrow, 2).Value
cboTutor.Text = r.Cells(currentrow, 3).Value
txtSessions.Value = r.Cells(currentrow, 4).Value
txtStartDate.Value = r.Cells(currentrow, 5).Value
txtEndDate.Value = r.Cells(currentrow, 6).Value
txtPlaces.Value = r.Cells(currentrow, 7).Value

If currentrow = Range("A65536").End(xlUp).Row Then GoTo LastRec
currentrow = currentrow + 1
'This is the data entry
txtiardRef.Text = r.Cells(currentrow, 1).Value
'txtSessions = r.Cells(currentrow, 1).Value
txtCourse.Text = r.Cells(currentrow, 2).Value
cboTutor.Value = r.Cells(currentrow, 3).Value
txtSessions.Value = r.Cells(currentrow, 4).Value
txtStartDate.Value = r.Cells(currentrow, 5).Value
txtEndDate.Value = r.Cells(currentrow, 6).Value
txtPlaces.Value = r.Cells(currentrow, 7).Value


Exit Sub
LastRec:
MsgBox "You're at the last record!"
End Sub


Would you like the workbook?

Vern
 
Upvote 0

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top