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
7 1794 ADezii 8,834
Recognized Expert Expert
This is actually a 2-Step Process: - 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:
- Private Sub cboSoftware_BeforeUpdate(Cancel As Integer)
-
Dim intNumOfLicenses As Integer
-
-
If IsNull(Me![cboSoftware]) Then Exit Sub
-
-
intNumOfLicenses = DLookup("[s_Licenses Number]", "tblSoftware", "[s_Software Text] = '" & Me![cboSoftware] & "'")
-
-
If intNumOfLicenses = 0 Then
-
MsgBox "You have no Licenses remaining for " & Me![cboSoftware], vbExclamation, "No License Available"
-
Cancel = True 'Prevent Update of cboSoftware
-
End If
-
End Sub
- At some point, Update the Software Table and decrease the Number of Licenses for the chosen Software by 1:
- Dim intNumOfLicenses As Integer
-
-
If IsNull(Me![cboSoftware]) Then Exit Sub
-
-
intNumOfLicenses = DLookup("[s_Licenses Number]", "tblSoftware", "[s_Software Text] = '" & Me![cboSoftware] & "'")
-
-
If intNumOfLicenses = 0 Then
-
MsgBox "You have no Licenses remaining for " & Me![cboSoftware], vbExclamation, "No License Available"
-
Cancel = True 'Prevent Update of cboSoftware
-
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).
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.
ADezii 8,834
Recognized Expert Expert - Dim strSQL As String
-
-
strSQL = "UPDATE tblSoftware SET tblSoftware.[s_Licenses Number] = (tblSoftware.[s_Licenses Number] - 1) " & _
-
"WHERE tblSoftware.[s_Software Text] = '" & Me![cboSoftware] & "';"
-
-
CurrentDb.Execute strSQL, dbFailOnError
Thanks gonna try it right away (and yes iam spamming refresh this website and my mailbox every 5seconds :P
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: - 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?
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?:
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.
Sign in to post your reply or Sign up for a free account.
Similar topics |
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...
|
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...
|
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...
|
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...
|
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...;...
| |
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...
|
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 &...
|
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.
...
|
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...
|
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...
|
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,...
| |
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,...
|
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...
|
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...
|
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,...
|
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...
|
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...
| |
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 ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |