-
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
-
Re: can't save combobox
Hi topsykretts... Welcome to the forums...:wave:
Try refreshing the recordset (b) after you update the record(in save button) :wave:
-
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.