hi,
i need help im new to access, vba, sql,... and need to adapt this: - Private Sub Project_Number_Click()
-
If Me.Town.Column(2) = "" Or Me.Type.Column(2) = "" Then
-
Me.Project_Number = ""
-
Else
-
Me.Project_Number = Me.Town.Column(2) & "-" & Me.Type.Column(2) & "-" & Me.Form.CurrentRecord
-
End If
-
End Sub
to actually check for which number to use for that type of project in that town.
so instead of "Me.Form.CurrentRecord"
it should check the "Towns" table where in the "Column(3)" line = "Me.Town.Column(2)" for column in that line = "Me.Type.Column(2)" and add +1
thanks for helping :)
9 1725
First, it seems very strange that you would be using the values of a Combo box, rather than the index. Using the index is a much more proper way of doing things, and I can only presume that since you are looking at the value of the third column that the first column is (or should be) the index. The engine behind access works much more efficiently when using indexes, which is why they exist.
Second, the statement
it should check the "Towns" table where in the "Column(3)" line = "Me.Town.Column(2)" for column in that line = "Me.Type.Column(2)" and add +1
doesn't wuite make any sense to me.
Again, if you are using an index the value of the combo box should be the same as if you looked it up in the Towns table.
I am also confused as to why you are adding one to the "Type" value.
i came up with this but it keeps giving me 001 - Private Sub Numéro_du_projet_Click()
-
Compteur = Nz(DMax("Séquence", "Projets", "Localité=" & Me.Localité & " and " & "Type=" & Me.Type), 0) + 1
-
Me.Numéro_du_projet = Me.Localité.Column(2) & "-" & Me.Type.Column(2) & "-" & Format(Compteur, "000")
-
End Sub
-
this is what i have so far - Private Sub Numéro_du_projet_Click()
-
If Me.Localité.Column(2) = "" Or Me.Type.Column(2) = "" Then
-
Me.Numéro_du_projet = ""
-
Else
-
Compteur = Nz(DMax("Séquence", "Projets", "Localité=" & Me.Localité & " and " & "Type=" & Me.Type), 0) + 1
-
Me.Numéro_du_projet = Me.Localité.Column(2) & "-" & Me.Type.Column(2) & "-" & Format(Compteur, "000")
-
End If
-
End Sub
-
The comboboxes can be used to select the project(s) and I advise you to read the "cascading comboboxes" article ( http://bytes.com/topic/access/insigh...mbo-list-boxes)
The only problem left is assigning a new project for a Localité / type combination.
I would use a separate [New] button to trigger such an event.
There you can find the MAX([Nurméro du projet]) WHERE Localité and Type are from the comboboxes. When no record is returned start with 1 otherwise add 1 to the found MAX.
Getting the idea ?
Nic;o)
PS: It's better to use no spaces in table and fieldnames. I would use NurméroDuProjet,thus making the brackets "[" and "]" obsolete in queries...
here is a sample db
if it helps
thanks
Hi vartaxe,
I've posted in the past a sample that might come in handy: http://bytes.com/attachments/attachm...tbeforenew.zip
First I would recommend to use this Object/Action principle as it's the same way as Access works with tables/queries/etc. You get to see all of them and (by the right-click) you can activate the action you want (Edit/Delete/etc.).
By making a selection form with a subform with all Projets, the user will easily navigate to the needed projet.
Next the buttons on the right show the actions like [New], [Update] [Print], etc.
Finally this sample shows the way I add a new record. This is by inserting it on forehand (the position where you can determine the sequencenumber of the new projet) and when the user cancels the operation, by deleting the inserted record.
Just press the [New] button and see the two combo's [CodePrefix] and [RecType]. After selecting them you get a code like you need for your projet. Here however the [CodePrefix] determines the number and in your case both combo's are needed.
So for determing the sequence number you can use a count of the number of localité and type and add +1. (think of the NULL when it's a new combination, use the NZ() function!)
In this sample datadase the +1 is handled in the module "modEPMroutines"
Lot's of info in this sample, but hope you're able to extract some usefull guidelines for your database from.
Getting the idea ?
Nic;o)
can't get it to work - Private Sub Numéro_du_projet_Click()
-
If Len(Me.Numéro_du_projet & "") < 1 Then
-
ElseIf Me.Localité.Column(2) = "" Or Me.Type.Column(2) = "" Then
-
MsgBox "Veuillez renseigner la localité et le type de projet."
-
Else
-
tSeq = Nz(DMax("Séquence", "Projets", "Localité=" & Me.Localité & " and " & "Type=" & Me.Type))
-
hiCount = Nz(DLookup("Compteur", "Projets", "Séquence=" & tSeq), 0) + 1
-
Me.Numéro_du_projet = Me.Localité.Column(2) & "-" & Me.Type.Column(2) & "-" & Format(Compteur, "000")
-
End If
-
End Sub
-
it is making me go nuts - Private Sub Numéro_du_projet_Click()
-
If Len(Me.Numéro_du_projet & "") < 1 Then
-
If Me.Localité.Column(2) = "" Or Me.Type.Column(2) = "" Then
-
MsgBox "Veuillez renseigner la localité et le type de projet."
-
Exit Sub
-
End If
-
tSeq = Nz(DMax("Séquence", "Projets", "Localité='" & Me.Localité.Column(2) & "' and " & "[Type]='" & Me.Type.Column(2) & "'"), 0)
-
hiCount = Nz(DLookup("Compteur", "Projets", "Compteur=" & tSeq & ""), 0) + 1
-
Me.Numéro_du_projet = Me.Localité.Column(2) & "-" & Me.Type.Column(2) & "-" & Format(hiCount, "000")
-
End If
-
End Sub
-
So Vartaxe, what is making you nuts?
What do you want to happen and what is actually happening?
Sign in to post your reply or Sign up for a free account.
Similar topics
by: jaad |
last post by:
Hello,
I have a database that was written in access 2007 on my pc. I wanted to work off site with the database so I uploaded it onto my laptop which is loaded with access 2010 beta.
When I...
|
by: sierra7 |
last post by:
It seems Access 2010 is associating an 'input mask' or field type with a combo box when a form is opened, even though there is no Format setting on the control.
I have a form which has been...
|
by: Alan Yim |
last post by:
Hi folks,
My company recently upgraded our Office suite from 2003 to 2010. The problem in particular is with an Access database that was originally designed in Access 2003. The code in question...
|
by: neelsfer |
last post by:
I got a new work laptop last week with Access 2010 pre-loaded.I also installed the new Office 2010 service pack 1.
I then loaded 2 of my regularly used Access 2007 + service pack 2 applications on...
|
by: jbrumbau |
last post by:
Hello,
In Access 2010/2007, how do you prevent users from flipping into design view from the ribbon? I do not want to hide the entire ribbon (DoCmd.ShowToolbar "Ribbon", acToolbarNo) or even the...
|
by: beacon |
last post by:
Hi everybody,
My title may not exactly describe my issue, so please forgive my lack of creativity today.
I've got a database that was created in Access 2003 that I've opened in Access 2010. I...
|
by: Sweeda |
last post by:
Hi guys, as you read in the title, I've got problems with more than one record in a table:
On opening the form that displays the field it appears the error 3197
"The Microsoft Jet database...
|
by: topher23 |
last post by:
A layout provides a grouping method for controls on a form or report. The two default layout types are Tabular (labels in form header, controls in detail), and Stacked (labels to the left, controls...
|
by: irslan rafique |
last post by:
Hi,
I am creating a database using Access 2010 Web Database.
I have two tables:
1-Maintbl with these fields:
1- Date 2- RTNo 3-DriverName 4- ConID 5-ConName
6- Zone 7-...
|
by: CLSkcab |
last post by:
Background:
Front End: MS Access 2010/VBA, Back End: MS SQL Server 2008
Can an Access 2010 program start another Access 2010 program and pass data to the one it starts?
Thanks in advance.
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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: 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...
| |