Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Validate data of subform using combobox from main form

$
0
0
Anyone help!!

I'm a student and a really beginner with access and never touch VBA before (and sorry if my english is all messy) anyway, I need help with how to validating data. I have a form with one subform, in the main form i have a combobox(Programme name) if a certain programme name is selected the combobox inside the subform will only give point to a certain subject

I've been playing with the VB and tried a few coding

Private Sub Form_Current()
Dim db As DAO.Database
Dim t2 As DAO.Recordset

Set db = CurrentDb
Set t2 = db.OpenRecordset("Table2 sub")

If programme.Value = "computer" Then

Do While Not Table2_sub.EOF
If Subject.Value = "Math" Or Me.Table2_sub!Subject.Value = "Geography" Then
Me.Table2_sub!Point.Value = 3
t2!.MoveNext
Loop
End If

End Sub

//////////////////////////////////

Private Sub programme_Change()
If programme.Value = "computer" And Me.Table2_sub!Subject.Value = "Math" Or Me.Table2_sub!Subject.Value = "Geography" Then
Me.Table2_sub!Point.Value = 3
End If
End Sub

this code worked but it only worked for one row in the subform...:eek:

any help will be appreciated..
Thanks

Attached Images
File Type: png Untitled.png (185.5 KB)
File Type: jpg Untitled.jpg (176.8 KB)

Viewing all articles
Browse latest Browse all 13329

Trending Articles