ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Loading values into a form on open. (https://www.excelbanter.com/excel-programming/278142-loading-values-into-form-open.html)

J. Vandenberg

Loading values into a form on open.
 
At the moment I have a form that opens with a button click. It's not a
Private Sub because the button I am using is an autoshape which just
has the macro assigned to it.

Sub newdayBtn_Click()
Application.ScreenUpdating = False
dailyFrm.Show 0 // Tried running it non modal too.

// Then I want it to load values on open into text boxes from cells in
a sheet.

Sheets("Data").Activate
dpr1 = Cells(25, 3)
dpr2 = Cells(25, 4)

// The dpr's are text box names. The thing is, unless I add another
action, ie. tab change, or form click, it will not load the values.

// I thought maybe a repaint would make them show up, but nada. I am
not sure how to initialize the form without a seperate routine, is
there a simple way to make this happen in one click?

Thanks,
-Joel

Ron de Bruin

Loading values into a form on open.
 
You must load the values in a event in the userform
Only load the Userform when you click the autoshape

Use this event in the Userform module

Private Sub UserForm_Initialize()
Me.TextBox1.Value = Sheets("Sheet1").Cells(25, 3).Value
End Sub



--
Regards Ron de Bruin
(Win XP Pro SP-1 XL2002 SP-2)
www.rondebruin.nl



"J. Vandenberg" wrote in message om...
At the moment I have a form that opens with a button click. It's not a
Private Sub because the button I am using is an autoshape which just
has the macro assigned to it.

Sub newdayBtn_Click()
Application.ScreenUpdating = False
dailyFrm.Show 0 // Tried running it non modal too.

// Then I want it to load values on open into text boxes from cells in
a sheet.

Sheets("Data").Activate
dpr1 = Cells(25, 3)
dpr2 = Cells(25, 4)

// The dpr's are text box names. The thing is, unless I add another
action, ie. tab change, or form click, it will not load the values.

// I thought maybe a repaint would make them show up, but nada. I am
not sure how to initialize the form without a seperate routine, is
there a simple way to make this happen in one click?

Thanks,
-Joel




J. Vandenberg

Loading values into a form on open.
 
Anyone? Bueller?

(J. Vandenberg) wrote in message . com...
At the moment I have a form that opens with a button click. It's not a
Private Sub because the button I am using is an autoshape which just
has the macro assigned to it.

Sub newdayBtn_Click()
Application.ScreenUpdating = False
dailyFrm.Show 0 // Tried running it non modal too.

// Then I want it to load values on open into text boxes from cells in
a sheet.

Sheets("Data").Activate
dpr1 = Cells(25, 3)
dpr2 = Cells(25, 4)

// The dpr's are text box names. The thing is, unless I add another
action, ie. tab change, or form click, it will not load the values.

// I thought maybe a repaint would make them show up, but nada. I am
not sure how to initialize the form without a seperate routine, is
there a simple way to make this happen in one click?

Thanks,
-Joel


Tom Ogilvy

Loading values into a form on open.
 
Sub newdayBtn_Click()
' Application.ScreenUpdating = False
dailyFrm.Load
With Sheets("Data")
dailyFrm.dpr1 = .Cells(25, 3).Value
dailyFrm.dpr2 = .Cells(25, 4).Value
End With
dailyFrm.Show 0
End Sub

--
Regards,
Tom Ogilvy

J. Vandenberg wrote in message
om...
Anyone? Bueller?

(J. Vandenberg) wrote in message

. com...
At the moment I have a form that opens with a button click. It's not a
Private Sub because the button I am using is an autoshape which just
has the macro assigned to it.

Sub newdayBtn_Click()
Application.ScreenUpdating = False
dailyFrm.Show 0 // Tried running it non modal too.

// Then I want it to load values on open into text boxes from cells in
a sheet.

Sheets("Data").Activate
dpr1 = Cells(25, 3)
dpr2 = Cells(25, 4)

// The dpr's are text box names. The thing is, unless I add another
action, ie. tab change, or form click, it will not load the values.

// I thought maybe a repaint would make them show up, but nada. I am
not sure how to initialize the form without a seperate routine, is
there a simple way to make this happen in one click?

Thanks,
-Joel





All times are GMT +1. The time now is 05:15 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com