Bypassing? intitialize() routine on UserForm

tungchiu

New Member
Joined
Nov 20, 2005
Messages
34
My UserForm has an initialize routine which amongst other things populates the UserForm TextBoxes with data from a spreadsheet, ie, on opening the UserForm, it defaults to the 1st recordset..

I have added a BeforeDoubleClick routine to allow me to doubleclidk on a specific row of data to bring up the DataForm with the selected data. The problem is that when I doubleclick, I get the default setting (of course)! Is there anyway around this?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Why don't you just reference the active row within the initialize event?
 
Upvote 0
Well if you post the current code it might help.

I'm just off out for a but but I'll check back later, but in the meantime I'm sure somebody else can help.
 
Upvote 0
Sorry for the delay - had an urgent call out that I had to deal with. This is an abridged version of the code that I am using. Hope it makes sense.

Private Sub UserForm_Initialize()
'Default setting - populates form with first recordset
Sheets("Sheet2").Activate
Range("B3").Select 'First row of data
Call Popul8TxtBxs
End Sub

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Excel.Range, _
Cancel As Boolean)
Dim curRow As Integer
ccurRow = ActiveCell.Offset(0, 0).Row
Cells(curRow, 2).Select 'Offsets calculated on column 2
Call Popul8TxtBxs
UserForm1.Show
End Sub

Private Sub Popul8TxtBxs()
'Populates UserForm1 TextBoxes with Sheet2 data
UserForm1.TextBox1.Text = ActiveCell.Offset(0, 1).Text 'Date txtbx
UserForm1.TextBox2.Text = ActiveCell.Offset(0, 0).Text 'Credit Note txtbx
UserForm1.TextBox3.Text = ActiveCell.Offset(0, 2).Text 'Cust Code txtbx
' -------------------etc etc -------------------------------------------
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,551
Members
449,088
Latest member
davidcom

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