Is anyone willing to...? 
Author Message
 Is anyone willing to...?

On Tue, 4 Aug 1998 06:03:38 +0800, "Jefferson Chang"

Quote:

>At the momet this program seems to
>work fine except when adding a record, the appropriate text box doesn't show
>the correct data fields of that particular record when the name in the
>listbox is clicked.

It sounds like you may not be either saving the record at the
appropriate time (do you have a specific button to do so, or trapping
entry back into the listbox?), or you may need to requery the listbox,
to force it to go back, re-read its recordset and pick up the new
record.

No, don't mail me your program :-)

Tim F

--



Fri, 19 Jan 2001 03:00:00 GMT  
 Is anyone willing to...?

Quote:

>It sounds like you may not be either saving the record at the
>appropriate time (do you have a specific button to do so, or trapping
>entry back into the listbox?),

I did check by open the VisData to monitor when exactly the record is added
into the database. I found that after the following code, new record with
new Cus_ID (primary index field) had been added. Any idea??

=================================================
Dim r as Recordset

[.....]

r.AddNew
r.Fields("Name") = Text1.text
[.....]
r.Update         '<<~ New record with new Cus_ID is added after this line
r.MoveLast     '<<~ Is this one causing the problem? But without this will
cause error when
                        '        adding List1.ItemData(List1.NewIndex) =
r.Fields("Cus_ID")

List1.AddItem Text1.text
List1.ItemData(List1.NewIndex) = r.Fields("Cus_ID")     'Add the new Cus_ID
into the listbox
List1.ListIndex = List1.NewIndex         '       This will set focus to the
name just added,
                                                                '        but
the wrong Cus_ID cause different info
                                                                '        is
being displayed.
Debug.Print "New Cus_ID is : ", List1.ItemData(List1.NewIndex)   ' But found
the Cus_ID is not new!!
=================================================

Quote:
>or you may need to requery the listbox, to force it to go back, re-read its
recordset
>and pick up the new record.

I do this at first and found no problem. However I dislike the annoying
effect when adding/deleting the record, the listbox will Refresh and re-read
the recordset. If there are few thousand names to be display, then reload
the entire name will seem slow don't you think?? Please correct me if I'm
wrong.

Thank you very much.



Sat, 20 Jan 2001 03:00:00 GMT  
 Is anyone willing to...?
I'm not quite sure what you are doing based on your post. It knid of looks
like you are directly referencing the IS number of the record you are adding
and that won't work because you cannot garrantee that they will always
correlate. This is how I repopulate my list box when I add somehting new to
it.
    CRecSet.MoveFirst
    For i = 1 To CRecSet.RecordCount
        'fMainForm.lstCfgName.AddItem (CRecSet.Fields(1))
        cboCFGName.AddItem CRecSet.Fields(1)
        CRecSet.MoveNext
    Next

Hope this helps,
Chris Stamey
------------------
http://www.Farther.com/VBAnswerNetwork

Quote:


>It sounds like you may not be either saving the record at the
>appropriate time (do you have a specific button to do so, or trapping
>entry back into the listbox?),

I did check by open the VisData to monitor when exactly the record is added
into the database. I found that after the following code, new record with
new Cus_ID (primary index field) had been added. Any idea??

=================================================
Dim r as Recordset

[.....]

r.AddNew
r.Fields("Name") = Text1.text
[.....]
r.Update         '<<~ New record with new Cus_ID is added after this line
r.MoveLast     '<<~ Is this one causing the problem? But without this will
cause error when
                        '        adding List1.ItemData(List1.NewIndex) =
r.Fields("Cus_ID")

List1.AddItem Text1.text
List1.ItemData(List1.NewIndex) = r.Fields("Cus_ID")     'Add the new Cus_ID
into the listbox
List1.ListIndex = List1.NewIndex         '       This will set focus to the
name just added,
                                                                '        but
the wrong Cus_ID cause different info
                                                                '        is
being displayed.
Debug.Print "New Cus_ID is : ", List1.ItemData(List1.NewIndex)   ' But found
the Cus_ID is not new!!
=================================================

Quote:
>or you may need to requery the listbox, to force it to go back, re-read its
recordset
>and pick up the new record.

I do this at first and found no problem. However I dislike the annoying
effect when adding/deleting the record, the listbox will Refresh and re-read
the recordset. If there are few thousand names to be display, then reload
the entire name will seem slow don't you think?? Please correct me if I'm
wrong.

Thank you very much.



Sun, 21 Jan 2001 03:00:00 GMT  
 Is anyone willing to...?
On Tue, 4 Aug 1998 17:12:48 +0800, "Jefferson Chang"

Quote:

>List1.AddItem Text1.text

>          'Add the new Cus_ID into the listbox
>List1.ItemData(List1.NewIndex) = r.Fields("Cus_ID")

>         'This will set focus to the name just added,
>         'but the wrong Cus_ID cause different info
>         'being displayed.
>List1.ListIndex = List1.NewIndex

>         ' But found the Cus_ID is not new!!
>Debug.Print "New Cus_ID is : ", List1.ItemData(List1.NewIndex)  

Hmmm - I suspect the r!Cus_ID field. If you are adding a new record,
has the recordset been updated? If it's an autonumber in particular,
these don't get allocated until different times in a record's life
cycle. Access 2 (I think) did it with the first keypress on a record;
A97 does it at record save time. Someone will correct me if I'm wrong.
In any case, you may be reading a field that has not yet been
initialised itself.  Apart from this, the logic works for me.

Best of luck.

Tim F

--



Sun, 21 Jan 2001 03:00:00 GMT  
 Is anyone willing to...?
I have had similar problems where new records were not immediately available
to other recordsets. After extensive investigation I think it was a hardware
function because the system write-cache was enabled. I was trying to read
the database before the cache was flushed and the new record written to
disk.
-
Kind Regards Mike Davies
Quote:

>On Tue, 4 Aug 1998 17:12:48 +0800, "Jefferson Chang"

>>List1.AddItem Text1.text

>>          'Add the new Cus_ID into the listbox
>>List1.ItemData(List1.NewIndex) = r.Fields("Cus_ID")

>>         'This will set focus to the name just added,
>>         'but the wrong Cus_ID cause different info
>>         'being displayed.
>>List1.ListIndex = List1.NewIndex

>>         ' But found the Cus_ID is not new!!
>>Debug.Print "New Cus_ID is : ", List1.ItemData(List1.NewIndex)

>Hmmm - I suspect the r!Cus_ID field. If you are adding a new record,
>has the recordset been updated? If it's an autonumber in particular,
>these don't get allocated until different times in a record's life
>cycle. Access 2 (I think) did it with the first keypress on a record;
>A97 does it at record save time. Someone will correct me if I'm wrong.
>In any case, you may be reading a field that has not yet been
>initialised itself.  Apart from this, the logic works for me.

>Best of luck.

>Tim F

>--




Thu, 25 Jan 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Anyone willing to help HS student?

2. Anyone willing to help HS student?

3. Anyone willing to be a mentor?

4. If anyone would be willing...

5. Is anyone willing to...?

6. GFA BASIC ???, anyone....anyone....anyone

7. I am trying to update a record, i am not using data control

8. I am learning VB.NET and am wondering....

9. I am trying to update a record, i am not using data control

10. I am in need of a programer. Willing to pay

11. I am willing to pay for help with WinBatch file. Interested ?

12. Help needed in finding Excel add-on or stand-alone program. Am willing to pay !

 

 
Powered by phpBB® Forum Software