473,473 Members | 2,044 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Code modification

158 New Member
This is a very handy little code that was given to me from a fine expert of this site a while back. It works perfectly, I just want to add something to it:

This code helps me pick out a Tenant from a table based on its TenantID. A thing that happens is if there is already a work order for a tenant with the same TenantID reference then I get into trouble.

Is there a way to look and see if first there is a Work Order that is already active for this TenantID?

Expand|Select|Wrap|Line Numbers
  1. Private Sub OKCmd_Click()
  2. If Len(Nz(Me.TenantID)) > 1 Then
  3.    DoCmd.RunCommand acCmdSaveRecord
  4.   Forms("WOrkorderF").Filter = "WOID=" & Me.WOID
  5.   Forms("WOrkorderF").FilterOn = True
  6.  DoCmd.Close
  7. Else
  8.    MsgBox "Tenant is mandatory, add one or press Cancel"
  9. End If
  10.  
  11. End Sub
-The table for my Tenants is called [TenantsT]

-The table where I store my Work Orders is Called [WorkOrderT]

The form used to filter a tenant is called [WOrkorderF] which get its value from a query called [WOSourceQ] with this code in it.

Expand|Select|Wrap|Line Numbers
  1. SELECT WorkOrderT.WOID, [FirstName] & " " & [LastName] & "     " & [Unit] & "  -  " & [Building] AS Tenant, WorkOrderT.Active, WorkOrderT.WorkOrderDate, WorkOrderT.TenantID, TenantsT.HomePhone, TenantsT.MobilePhone, LocationsT.LocID, BuildingLT.BuildingID
  2. FROM LocationsT RIGHT JOIN (BuildingLT RIGHT JOIN (TenantsT RIGHT JOIN WorkOrderT ON TenantsT.TenantID=WorkOrderT.TenantID) ON BuildingLT.BuildingID=TenantsT.BuildingID) ON LocationsT.LocID=TenantsT.LocID
  3. WHERE (((WorkOrderT.Active)=-1));
  4.  
If I missed anything please let me know. Thanks a bunch
Jan 30 '10 #1
7 1433
nico5038
3,080 Recognized Expert Specialist
This code helps me pick out a Tenant from a table based on its TenantID. A thing that happens is if there is already a work order for a tenant with the same TenantID reference then I get into trouble.
What trouble ?
Guess it's possible to have multiple Workorders for one tenant....

Nic;o)
Jan 31 '10 #2
jaad
158 New Member
The reason to have only one Work Order going per tenant at any given time is to keep the administration under control and simple. If it was just the Work Orders it wouldn't be such a big deal but for every Work Order that gets open I have to open a new Purchase Order, new Schedules with different people, New Journals, 4 invoices instead of one from the same contractor, 10 invoices instead of 1 for supplies and so on... Does that make sense to you?
Jan 31 '10 #3
NeoPa
32,556 Recognized Expert Moderator MVP
A relatively simple way to check would be to use DLookup(). Have you ever come across Domain Aggregate functions before in VBA (DLookup() is one such)?
Jan 31 '10 #4
jaad
158 New Member
Is there a spot in that code that show above that would be a good place to put the Dlookup in? Is it better to put it before or after or maybe right in the middle?
Jan 31 '10 #5
nico5038
3,080 Recognized Expert Specialist
I would take this "to the beginning", by not showing tenants having an order.
So the selection combo's query needs to exclude tenants that are having an order by using a so-called "outer-join" to the orders table. Having such a JOIN (double click the connection line in the query editor and make the tenants table "master") and by testing the OrderID being Null will give you the tenants that are OK.

Getting the idea ?

Nic;o)
Jan 31 '10 #6
NeoPa
32,556 Recognized Expert Moderator MVP
@jaad
That depends on what you want. The DLookup code will check whether the item exists already. Where do you want within your code?
Feb 1 '10 #7
jaad
158 New Member
thank you, I will give this a try, I'm more than certain that it will work...

Cheers
Feb 1 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: nathan_kent_bullock | last post by:
Assume I am using a class Foo. I want to find out the modification time of the file that that class was defined in. How would I go about this? If I could find out the name of the file that Foo...
2
by: janek | last post by:
My question How can I do something like this... in Builder: In ListBox I've got a list of the files (load by the FindDir) and what should I do to pull out from these files the size and the time...
3
by: stan | last post by:
I am working on some documentation in html format and I would really like to display the date the html file, itself was modified. I am writing my documentation in vi and the html server involved is...
10
by: malv | last post by:
I am involved in a major scientific algorithm design problem in which simulation of the underlying physics and visualization play an important role. Algorithm adaptation from run to run often...
0
by: Marco Segurini | last post by:
HI, my form contains a combobox and a propertygrid control. At each string of the combobox is associated an object. When I select a string of the combobox the associated object is selected in...
1
by: Henry Law | last post by:
(I posted this to comp.infosystems.www.browsers.misc but there seems to be very little traffic there. I can't see another suitable group; is it on topic here? If not, any suggestions as to...
2
by: sgMuser | last post by:
Hi, I am not a good developer of Javascript codes. Needs this help to make some modification to this famous free javascript from Anarchos. i am using this in one of my webpage. What it does is,...
4
by: IdleBrain | last post by:
Hello All, Is it possible to obtain the last Modified date for the source code from within the application? If yes, please let me know how it is done.
13
by: ts-dev | last post by:
Is it possible to prevent modification of a python file once its been deployed? File permissions of the OS could be used..but that doesn't seem very secure. The root of my question is verifying...
2
by: Unpopular | last post by:
void directory::modification()//??????????? { clrscr(); cout<< "\n\t @@@@@@ @@@@@ @@@@@ @@@@@@ @@@@@ @ @ @@@@@@ "; cout<< "\n\t=====@ @ @ @ @ @ @@...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.