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

Home Posts Topics Members FAQ

How to calculate licenses left using query?

5 New Member
Hello all,

Iam a newby to Access but for learning purposes iam building an Access Database in Access 2007 (a CMDB). In the database i got so called configurations. In a configurations there are persons, computers, model, OS, software etc. linked.

For the Software part I want a Query that calculates how many licences I got left. But I really cant figure out how I can do that... So iam hoping if someone can help me on track.

Some DB info:
Iam keeping it smaller then my whole DB looks like.
TblConfig:
c_ComputerName Text PK
c_ParentOU Text
c_PasswordAge Number
c_Model Text
c_Tagnumber Text
c_Memory Text
c_Bios Text
c_Users Text
c_Operating system Text
c_Software Text
c_Opmerking Text
c_Garantue Number
c_Location Number

tblSoftware:
s_SoftID AutoNumber
s_Software Text (PK)
s_Licenses Number
I used not the autonumber as PK due it gave me some trouble. I will explain below.

Under the s_Software i got my Software like Office 2007 etc. And on s_Licenses the amount of licences a software got.

In the form configuration you can select the software a configuration/pc got. This selection is saved in c_Software. But this field is a Multiple Value field (I know its probably evil but I wanted that user could select multiple selections).

So I was figuring that if you select software you can AfterUpdate a Query event that will change how many Licences I got left. Hope I was clear enough..

Thanks in advance :)

Jerx
Jan 23 '11 #1
7 1794
ADezii
8,834 Recognized Expert Expert
This is actually a 2-Step Process:
  1. When a Software is selected, let's say from a Combo Box named cboSoftware, you must make sure that you have at least 1 License remaining for that Software. If there are none left, Cancel the Update of the Combo Box. This could be done in the BeforeUpdate() Event of the Combo Box:
    Expand|Select|Wrap|Line Numbers
    1. Private Sub cboSoftware_BeforeUpdate(Cancel As Integer)
    2. Dim intNumOfLicenses As Integer
    3.  
    4. If IsNull(Me![cboSoftware]) Then Exit Sub
    5.  
    6. intNumOfLicenses = DLookup("[s_Licenses Number]", "tblSoftware", "[s_Software Text] = '" & Me![cboSoftware] & "'")
    7.  
    8. If intNumOfLicenses = 0 Then
    9.   MsgBox "You have no Licenses remaining for " & Me![cboSoftware], vbExclamation, "No License Available"
    10.     Cancel = True       'Prevent Update of cboSoftware
    11. End If
    12. End Sub
  2. At some point, Update the Software Table and decrease the Number of Licenses for the chosen Software by 1:
    Expand|Select|Wrap|Line Numbers
    1. Dim intNumOfLicenses As Integer
    2.  
    3. If IsNull(Me![cboSoftware]) Then Exit Sub
    4.  
    5. intNumOfLicenses = DLookup("[s_Licenses Number]", "tblSoftware", "[s_Software Text] = '" & Me![cboSoftware] & "'")
    6.  
    7. If intNumOfLicenses = 0 Then
    8.   MsgBox "You have no Licenses remaining for " & Me![cboSoftware], vbExclamation, "No License Available"
    9.     Cancel = True       'Prevent Update of cboSoftware
    10. End If
P.S. - I accidentially posted duplicate code, I'll Post the other Code Updating the License Number Count when I get to work tomorrow evening, since that is where the Code is.(LOL).
Jan 23 '11 #2
Jerx
5 New Member
Cool, iam gonna try this tomorrow and report in later then :)

Edit: Ahh i see you just posted duplicate :P I will wait for it.
Jan 23 '11 #3
ADezii
8,834 Recognized Expert Expert
Expand|Select|Wrap|Line Numbers
  1. Dim strSQL As String
  2.  
  3. strSQL = "UPDATE tblSoftware SET tblSoftware.[s_Licenses Number] = (tblSoftware.[s_Licenses Number] - 1) " & _
  4.          "WHERE tblSoftware.[s_Software Text] = '" & Me![cboSoftware] & "';"
  5.  
  6. CurrentDb.Execute strSQL, dbFailOnError
Jan 24 '11 #4
Jerx
5 New Member
Thanks gonna try it right away (and yes iam spamming refresh this website and my mailbox every 5seconds :P
Jan 24 '11 #5
Jerx
5 New Member
Ok ive been trying a bit but it seems to go wrong. Say that i got 2 forms, 1 is a configuration form where you can select Software, model, tagnumbers etc. And i got a form Software where they can Add software and licences.

In the form configuration is a list. So I figured that I implement the first part of the code in the before update and edit the cboSoftware to lstSoftware.

1 thing it crashes on is:
Expand|Select|Wrap|Line Numbers
  1. intNumOfLicenses = DLookup("[s_Aantal]", "tblSoftware", "[s_Software] = '" & Me![LSTSoftware] & "'")
So I think its looking for S_Aantal or S_Software form/table in the form configuration?
Jan 24 '11 #6
ADezii
8,834 Recognized Expert Expert
What does the [s_Aantal] Field have to do with the Number of Licenses for a given Software Package?:
Jan 24 '11 #7
Jerx
5 New Member
Sorry S_Aantal = S_License (i changed due its a dutch word :P My mistake ;o ) But the question still stands.. thanks for putting your time in it though.
Jan 24 '11 #8

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

Similar topics

0
2429
by: Marek Lewczuk | last post by:
Hello, I have a strange problem, maybe some of you will be able to explain me something. I use LEFT JOIN as a substitute for subselects. It's true that many subselects can be rewriten using LEFT...
3
23072
by: Ian Boyd | last post by:
i know nothing about DB2, but i'm sure this must be possible. i'm trying to get a client to create a view (which it turns out is called a "Logical" in DB2). The query needs a LEFT OUTER JOIN, but...
6
29920
by: Martin Lacoste | last post by:
Ok, before I headbutt the computer... don't know why when I add criteria in a query, I get an 'invalid procedure call'. I also don't know why after searching the help in access, the various access...
3
53710
by: GL | last post by:
Hi, Is there a way to add a field to an existing table using a query of some sort (without needing to manually add a field to the table). I know how to do it with a make table query, but I have...
2
1951
by: StaZ | last post by:
Hello, I would simply like to know if there's a way to disable the "feature" of MS Access that rewrites your queries "correctly"... This feature makes this : ...WHERE SomeBooleanField...;...
4
1525
by: bhargav.desai | last post by:
Hello Gurus, I need help! I have two table, tblCurrent and tblPrevious. What I want to join the tables, and create a new table that have matching records from both the tables, plus this new...
8
1310
by: Melinda | last post by:
Our website (currently done in simple HTML - using front page) is hosted by a 3rd party hosting firm, & the servers have ASP.NET installed. I have a copy of VS.NET 2003 (from a friend, installed &...
3
13401
by: torpecool | last post by:
Hello Everyone, I have been searching around for an answer to this question with no luck. I hope that some of you may have a couple of good ideas I could try. I am running MySQL 4.1.20. ...
0
2271
by: yeahuh | last post by:
Quick and dirty version. Godaddy server using MySQL 4.0.24 I’m trying a left join to obtain id’s in table A(cars) that are NOT in car_id in table B(newspaper): *This is a cut down version...
4
2733
by: Sector 7G | last post by:
I'm working with a SQL query for a Human Resources database. Its intended purpose is to find all the paycheck records with a check date (prckhist.chkdate ) more recent than eleven days past the...
0
7100
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
7126
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7175
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
7330
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...
0
5434
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4865
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
4559
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
1378
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
598
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.