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?
 

Some videos you may like

Excel Facts

Enter current date or time
Ctrl+: enters current time. Ctrl+; enters current date. Use Ctrl+: Ctrl+; Enter for current date & time.

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,061
Office Version
  1. 365
Platform
  1. Windows
Why don't you just reference the active row within the initialize event?
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,061
Office Version
  1. 365
Platform
  1. Windows
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.
 

tungchiu

New Member
Joined
Nov 20, 2005
Messages
34
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
 

Watch MrExcel Video

Forum statistics

Threads
1,118,821
Messages
5,574,515
Members
412,599
Latest member
Schu94
Top