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 April 19th, 2004, 02:30 PM
Authorized User
 
Join Date: Apr 2004
Posts: 45
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to lguzman
Default Displaying text depending on the value of a field

I got 3 tables.

Table(A) holds a unique identifier and a description field. I would like to display the description field in a form.

However this is depending on the information held on another table(B). If the information in table(B) is null, I would like to display the information found on a third table(C).

[u]Here is the scenario.</u>
My first table(A) holds the names of companies and their unique identifiers. The second table holds information of divisions within an organization. The third table(C) holds information on the organizations. I need to know who I should charge, the head office (organization) or the divisions themselves. So if no info exists on the second table(B) -division- then I want to charge by default the Organization table(C) or any third party that has agreed to pay for this organization.

So what I am looking to do is, find who (table(B) or table(C)) and then withdraw the description from table(A) and display it.

I have come up with the following:

Public Function GetAccountingBillTo()
Dim TempNum As Integer
Dim TempName As String

If AccountingBilltoC = "" Then
   TempNum = DLookup("[AccountingBilltoO]", "Organizations", "[Name] =" & Customers!OrganizationName)
   If TempNum <> "" Then
      TempName = DLookup("[sName]", "TblAccountingBillToDropDownInfo", "[tempnum]=" & Organizations!AccountingBilltoO)
   Else
       TempName=" "
   End If
Else
   TempName = DLookup("[sName]", "TblAccountingBillToDropDownInfo", "[tempnum]=" & Customers!AccountingBilltoC)
End If
Text179 = TempName
End Function


This however gets me a Run-Time error '424'. Object required.


Help!

[u]Thanks.</u>

[LGuzman]
__________________
[LGuzman]
 
Old May 30th, 2004, 06:14 PM
Authorized User
 
Join Date: Oct 2003
Posts: 53
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello LGuzman,
First of all, your function must have a result, you have Text179 = TempName, it should be
GetAccountingBillTo = TempName, & I believe your function decleration should be Public Function GetAccountingBillTo() as String.
Then on the form, fired by whatever event you choose, Text179 = GetAccountingBillTo.
I'm thinking also, that you shouild be checking for Null , not empty strings.
If IsNull(AccountingBilltoC) Then.... or
If Not IsNull(AccountingBilltoC) Then....
Good Luck!






Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Text(Sql Server Text Field) to Image(JPG) srinivas72 ADO.NET 2 February 13th, 2009 06:31 PM
Displaying Text using CSS austinf CSS Cascading Style Sheets 3 October 11th, 2007 02:58 PM
Memo field not displaying meichmann SQL Server ASP 3 August 31st, 2006 11:36 AM
Displaying OLE object field in a form Rick Neifeld Access VBA 0 December 24th, 2003 02:16 PM
Displaying field selection meiyeen JSP Basics 0 July 13th, 2003 11:22 PM





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