Results 1 to 3 of 3

Thread: can't save combobox

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2010
    Posts
    1

    can't save combobox

    I'm so newbie. Badly need ur help. on a form i put a combobox retrieved from a different table. it works fine. but when i filled in all the entries and saved them, it didn't save. still empty. before is used the combo, it was just fine.
    here's the script ( a little), for a start. btw, it's vb6.
    Code:
    Private Sub Form_load()
    Set wjt = CreateWorkspace("", "admin", "", dbUseJet)
    Set a = wjt.OpenDatabase("D:\My Documents\VB_Practice\db1.mdb")
    Set a = OpenDatabase("D:\My Documents\VB_Practice\db1.mdb")
    Set b = a.OpenRecordset("student")
    Set f = a.OpenRecordset("select distinct (class)  from rombel")
    
    cboclass.Text = f!class
        
            With cboclass
            .Clear
       On Error Resume Next
       If f.RecordCount = 0 Then
       MsgBox "type in data", vbOKOnly
        
            Else
                      f.MoveFirst
            Do Until f.EOF
                .AddItem f(0)
            
                f.MoveNext
        
            Loop
           End If
           End With
     
       Return
    
        If b.RecordCount = 0 Then
    Call empty
    Else
    b.MoveFirst
    End If
    change= False
    End Sub
    Here's the save script:
    Code:
    Private Sub save_Click()
    b.AddNew
    b!no = tno.Text
    b!nisn = tnisn.Text
    b!class = cboclass.Text
    b!name = tname.Text
    b!sex= tsex.Text
    b.Update
    Call empty
    tno.SetFocus
    End Sub
    after clicking save, and click the next button, it show "no current record" [runtime error '3021']

    i assumed it's bcoz of the combobox which is probably not properly set.
    any idea? please.

    tx b4
    Last edited by si_the_geek; Sep 12th, 2010 at 01:52 PM. Reason: added Code tags

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: can't save combobox

    Hi topsykretts... Welcome to the forums...

    Try refreshing the recordset (b) after you update the record(in save button)

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    PowerPoster
    Join Date
    Jul 2006
    Location
    Maldon, Essex. UK
    Posts
    6,334

    Re: can't save combobox

    Also, I suggest you remove the 'On Error Resume Next" - it might not help with this problem but it will help you in the long run.

    What that statement does is to ignore any errors that might cause the program to abort. That can lead to many misleading problems which can take forever to work out when you're debugging.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width