Wrox Programmer Forums
|
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 September 12th, 2006, 08:18 AM
Authorized User
 
Join Date: Jul 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default Populate a field

Hi Everyone

I don’t have that much VB experience, maybe someone can help me. I have 4 variables called: A, B, C and Z, what I want to do is update Z with the value of A when A is not blank and B and C is blank, other wise if A and B is both not blank and C is blank then Z should be updated with B's value and so on, the table's name is TBL. Below is the code that I have tried and failed, could someone please help me?


Private Sub Command0_Click()
Dim A As String
Dim B As String
Dim C As String
Dim Z As String

A = [TBL].[A]
B = [TBL].[B]
C = [TBL].[C]
Z = [TBL].[Z]

    If (A Is Not blank And B Is blank And C Is blank) Then Z = (A)
End If
End Sub


Thanks
Hennie



 
Old September 13th, 2006, 08:27 AM
Authorized User
 
Join Date: Jul 2006
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Does anyone have an idea for me?

 
Old September 13th, 2006, 12:32 PM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

How do you want to do this? Do you want it to happen when someone fills out a form, or are you trying to update lots of records in an Update query, etc?

It would be easy in an update query on the table. You could do this in a series of Update queries just to make it very easy:

Update query:
A criteria: <>""
B criteria: <>""
C criteria: =""
Z update: [A]

Then just run the query.

Does this help?






mmcdonal





Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a View "Name" field & Populate bren582 SQL Server 2005 2 February 11th, 2008 10:28 PM
Populate field names upon selection from 1st DDL? InsouciantCoquette Classic ASP Databases 0 February 26th, 2006 11:23 PM
How can I auto-populate two MS Word document field kenn_rosie ASP.NET 1.0 and 1.1 Basics 0 February 15th, 2006 03:59 AM
Populate Auto-Number Field JeffGirard Access 2 August 26th, 2005 06:49 AM
Auto Populate a field ? mar0364 Classic ASP Databases 4 July 9th, 2004 11:10 AM





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