Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hair Pulling Problem...

I have spent way to much time on this. I wish my programming skills were much better...

I have a form with 3 textboxes and 1 listbox. The listbox is populated with items from a range. When the listbox is clicked, it populates the textboxes. This works great.

Private Sub Data_LtBx_Click()
Set SourceData = Range(Data_LtBx.RowSource)
SourceIndex = Data_LtBx.ListIndex
PrevMRN_TxBx.Value = SourceData.Offset(SourceIndex, 0).Resize(1, 1).Value
PrevName_TxBx.Value = SourceData.Offset(SourceIndex, 4).Resize(1, 1).Value
PrevDate_TxBx.Value = SourceData.Offset(SourceIndex, 10).Resize(1, 1).Value
End Sub

Now if I change the first textbox "PrevMRN_TxBx" and use the following sub:

Private Sub Change_CoBn_Click()
Set SourceData = Range(Data_LtBx.RowSource)
SourceIndex = Data_LtBx.ListIndex

SourceData.Offset(SourceIndex, 0).Resize(1, 1).Value = PrevMRN_TxBx.Value
SourceData.Offset(SourceIndex, 4).Resize(1, 1).Value = PrevName_TxBx.Value
SourceData.Offset(SourceIndex, 10).Resize(1, 1).Value = PrevDate_TxBx.Value
End Sub

The change is made and I am a happy customer, but if I change either of the other 2 textboxes, the values are not changed. I have run several tests and the numbers for the offsets are correct, but no update.

What am I doing wrong? (Besides trying to program)
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Hair Pulling Problem...

Troy,

The problem is that the commandbutton is triggering the Listbox click event,
causing it to be refreshed again.

Try this version

Dim fReEnter As Boolean

Private Sub Data_LtBx_Click()
If Not fReEnter Then

fReEnter = True

Set SourceData = Range(Data_LtBx.RowSource)
SourceIndex = Data_LtBx.ListIndex
PrevMRN_TxBx.Value = SourceData.Offset(SourceIndex, 0).Resize(1,
1).Value
PrevName_TxBx.Value = SourceData.Offset(SourceIndex, 4).Resize(1,
1).Value
PrevDate_TxBx.Value = SourceData.Offset(SourceIndex, 10).Resize(1,
1).Value

fReEnter = False

End If
End Sub

Private Sub Change_CoBn_Click()
If Not fReEnter Then

fReEnter = True

Set SourceData = Range(Data_LtBx.RowSource)
SourceIndex = Data_LtBx.ListIndex

SourceData.Offset(SourceIndex, 0).Resize(1, 1).Value =
PrevMRN_TxBx.Value
SourceData.Offset(SourceIndex, 4).Resize(1, 1).Value =
PrevName_TxBx.Value
SourceData.Offset(SourceIndex, 10).Resize(1, 1).Value =
PrevDate_TxBx.Value
Application.EnableEvents = True

fReEnter = False

End If
End Sub



--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"Troy" wrote in message
...
I have spent way to much time on this. I wish my programming skills were

much better...

I have a form with 3 textboxes and 1 listbox. The listbox is populated

with items from a range. When the listbox is clicked, it populates the
textboxes. This works great.

Private Sub Data_LtBx_Click()
Set SourceData = Range(Data_LtBx.RowSource)
SourceIndex = Data_LtBx.ListIndex
PrevMRN_TxBx.Value = SourceData.Offset(SourceIndex, 0).Resize(1,

1).Value
PrevName_TxBx.Value = SourceData.Offset(SourceIndex, 4).Resize(1,

1).Value
PrevDate_TxBx.Value = SourceData.Offset(SourceIndex, 10).Resize(1,

1).Value
End Sub

Now if I change the first textbox "PrevMRN_TxBx" and use the following

sub:

Private Sub Change_CoBn_Click()
Set SourceData = Range(Data_LtBx.RowSource)
SourceIndex = Data_LtBx.ListIndex

SourceData.Offset(SourceIndex, 0).Resize(1, 1).Value =

PrevMRN_TxBx.Value
SourceData.Offset(SourceIndex, 4).Resize(1, 1).Value =

PrevName_TxBx.Value
SourceData.Offset(SourceIndex, 10).Resize(1, 1).Value =

PrevDate_TxBx.Value
End Sub

The change is made and I am a happy customer, but if I change either of

the other 2 textboxes, the values are not changed. I have run several tests
and the numbers for the offsets are correct, but no update.

What am I doing wrong? (Besides trying to program)



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hair Pulling Problem...

Thank-you for your help. It was very helpful.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Hair Pulling Problem...

This worked for me. Trying to change data in the rowsource can be
troublesome:

Private Sub Change_CoBn_Click()
Set SourceData = Range(Data_LtBx.RowSource)
sRwSource = Data_LtBx.RowSource
SourceIndex = Data_LtBx.ListIndex
Data_LtBx.RowSource = ""
idex = Data_LtBx.ListIndex
SourceData.Offset(SourceIndex, 0).Resize(1, 1).Value =
PrevMRN_TxBx.Value
SourceData.Offset(SourceIndex, 4).Resize(1, 1).Value =
PrevName_TxBx.Value
SourceData.Offset(SourceIndex, 10).Resize(1, 1).Value =
PrevDate_TxBx.Value
Data_LtBx.RowSource = sRwSource
Date_ListIndex = idex
End Sub

--
Regards,
Tom Ogilvy


"Troy" wrote in message
...
I have spent way to much time on this. I wish my programming skills were

much better...

I have a form with 3 textboxes and 1 listbox. The listbox is populated

with items from a range. When the listbox is clicked, it populates the
textboxes. This works great.

Private Sub Data_LtBx_Click()
Set SourceData = Range(Data_LtBx.RowSource)
SourceIndex = Data_LtBx.ListIndex
PrevMRN_TxBx.Value = SourceData.Offset(SourceIndex, 0).Resize(1,

1).Value
PrevName_TxBx.Value = SourceData.Offset(SourceIndex, 4).Resize(1,

1).Value
PrevDate_TxBx.Value = SourceData.Offset(SourceIndex, 10).Resize(1,

1).Value
End Sub

Now if I change the first textbox "PrevMRN_TxBx" and use the following

sub:

Private Sub Change_CoBn_Click()
Set SourceData = Range(Data_LtBx.RowSource)
SourceIndex = Data_LtBx.ListIndex

SourceData.Offset(SourceIndex, 0).Resize(1, 1).Value =

PrevMRN_TxBx.Value
SourceData.Offset(SourceIndex, 4).Resize(1, 1).Value =

PrevName_TxBx.Value
SourceData.Offset(SourceIndex, 10).Resize(1, 1).Value =

PrevDate_TxBx.Value
End Sub

The change is made and I am a happy customer, but if I change either of

the other 2 textboxes, the values are not changed. I have run several tests
and the numbers for the offsets are correct, but no update.

What am I doing wrong? (Besides trying to program)



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default Hair Pulling Problem...

Thank-you again for your help.


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
excel formula i'm pulling my hair out murksaxet Excel Discussion (Misc queries) 4 August 1st 06 08:21 PM
Pulling my hair out here gtg689a Excel Worksheet Functions 0 April 5th 06 03:42 PM
Pulling my hair out, need some help building a formula Jackanorry Excel Worksheet Functions 2 June 23rd 05 04:05 PM
combo box problem I am pulling my hair out about!!!! TerryStyles Excel Worksheet Functions 1 April 11th 05 02:41 PM
Pulling hair out with VLOOKUP Confused Excel Worksheet Functions 5 November 22nd 04 05:05 PM


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

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"