Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2012, 07:52 AM
Registered User
 
Join Date: Oct 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Validate subform data using combobox from main form

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 data validation using VBA. 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 which is the subject will only give point to a certain subject else the point will be 0. The Point will be in another column in the subform..

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

when i tried to change to the next record an error pop-up and it show the coding saying LOOP without DO
//////////////////////////////////

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...

any help will be appreciated..
Thanks





Similar Threads
Thread Thread Starter Forum Replies Last Post
Filter subform from button on main form kawi6rr Forum and Wrox.com Feedback 0 August 11th, 2010 04:29 PM
Synchronizing main form w/subform (i.e. backward) paladin Access VBA 7 April 19th, 2007 06:40 AM
Moving total from Subform to Main Form Shepwad Access 1 March 10th, 2006 10:57 AM
updating main form from subform dartcoach Access 6 April 28th, 2005 08:27 AM
Filter subform from main form DBoulos Access VBA 2 October 30th, 2003 12:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.