473,386 Members | 1,817 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Needing Help on Relations, Is there anyone that can help?

Hello,

I am somewhat new at access 2003 and I really need some assistance on this so I can continue on. Any assistance would help.

I want to retrieve last sequential number in Field1 in Table1 to put in Field 3 of Table2. How do I do this? I tried Nz(DMax("[Field1]","Table1"))+1 in the default value of Field 3 in Table2 but it came up with Unknown Function 'NZ' in validation expression. Can someone help....

Thanks

Dave
Mar 4 '08 #1
5 1190
Stewart Ross
2,545 Expert Mod 2GB
Hello,

I am somewhat new at access 2003 and I really need some assistance on this so I can continue on. Any assistance would help.

I want to retrieve last sequential number in Field1 in Table1 to put in Field 3 of Table2. How do I do this? I tried Nz(DMax("[Field1]","Table1"))+1 in the default value of Field 3 in Table2 but it came up with Unknown Function 'NZ' in validation expression. Can someone help....

Thanks

Dave
Hi David. You can't place such an expression in the default value property of the table itself - the error message is a bit misleading here. You can put such an expression into the default value of a control bound to the value of Field1 on a user data entry form, preceded by an = sign to indicate the use of an expression, as shown below. Note the use of a zero in the Nz function below to return a 0 if the field is null:
Expand|Select|Wrap|Line Numbers
  1.  =Nz(DMax("[Field1]","Table1", 0))+1
If you want to prevent users changing the value, you also need to set two other properties for the field: enabled to No and locked to Yes.

-Stewart
Mar 4 '08 #2
Hi David. You can't place such an expression in the default value property of the table itself - the error message is a bit misleading here. You can put such an expression into the default value of a control bound to the value of Field1 on a user data entry form, preceded by an = sign to indicate the use of an expression, as shown below. Note the use of a zero in the Nz function below to return a 0 if the field is null:
Expand|Select|Wrap|Line Numbers
  1.  =Nz(DMax("[Field1]","Table1", 0))+1
If you want to prevent users changing the value, you also need to set two other properties for the field: enabled to No and locked to Yes.

-Stewart
Stewart,

Is there a expression you can use to take the next consecutive unused number of one field of table1 and put it into another field in table2 so that the field in Table1 gets updated at the same time table2 is requesting the next unused consecutive numver. I am assuming you link the tables together but I am not sure about pulling the data out of one to put in the other or am I going in the wrong direction? Does any of this makes since?

David
Mar 4 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi David. A table design often has a unique numeric identifier as the primary key. Access provides an autonumber field which automatically increments for each record, although it has some quirks which mean it is not always the best choice.

Generally, linking the key fields in tables participating in one-to-many relationships can be done using a user form with a subform for the many-side relationship.The linkage of parent and child key fields between the form and subform takes care of setting key values between tables auotmatically.

Without knowing more about your database design its hard to advise you more specifically.

There is a good HowTo article in the forum at http://www.thescripts.com/forum/thread585228.html on table design and normalisation, which is an essential first step in designing any database. Any good book on database design will also help you with understanding the basics of relations between tables.

-Stewart
Mar 4 '08 #4
Hi David. A table design often has a unique numeric identifier as the primary key. Access provides an autonumber field which automatically increments for each record, although it has some quirks which mean it is not always the best choice.

Generally, linking the key fields in tables participating in one-to-many relationships can be done using a user form with a subform for the many-side relationship.The linkage of parent and child key fields between the form and subform takes care of setting key values between tables auotmatically.

Without knowing more about your database design its hard to advise you more specifically.

There is a good HowTo article in the forum at http://www.thescripts.com/forum/thread585228.html on table design and normalisation, which is an essential first step in designing any database. Any good book on database design will also help you with understanding the basics of relations between tables.

-Stewart

Stewart,

Thanks for the help, I am now getting somewhere, one more question. How do I get the same result for text fields I tried substituting the numeric value with text but it gave me the last alpha value which would be "w" in this case but I want the last inputted value in the field. I used the substitution below

=Nz(DMax("[StudentCompany]","Master Cert Database"))

but like I commented above it didnt work. What solution do you have for this?

David
Mar 4 '08 #5
Stewart Ross
2,545 Expert Mod 2GB
Stewart,

Thanks for the help, I am now getting somewhere, one more question. How do I get the same result for text fields I tried substituting the numeric value with text but it gave me the last alpha value which would be "w" in this case but I want the last inputted value in the field. I used the substitution below

=Nz(DMax("[StudentCompany]","Master Cert Database"))

but like I commented above it didnt work. What solution do you have for this?

David
Hi David. If what you want is to set the default value of a field from the last value entered this can be done using a small amount of visual basic coding on the After Update event of the field concerned (assuming that you are using an Access Form for data entry). Open the form in design view and double-click on the field in the form to bring up its properties sheet. Right-click on the After Update property, select Build, Code, and add the following code into the skeleton Sub ctrlname_Afterupdate() procedure which Access will create for you:

Expand|Select|Wrap|Line Numbers
  1. Me![yourcontrolname].DefaultValue = "'" & Me![yourcontrolname] & "'"
substituting the real name of your control for yourcontrolname.

There is no simple function that does this for you without coding.

-Stewart
Mar 4 '08 #6

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

Similar topics

0
by: Nicolas STAMPF | last post by:
Hello, I've just read documentation for both packages, and I can't seem to decide which one to use. I have some simple database things to do, but I'd like to have my code prepared for...
2
by: DelphiBlue | last post by:
I have a Nested Datagrid that is using a data relations to tie the parent child datagrids together. All is working well with the display but I am having some issues trying to sort the child...
1
by: Brian Kedersha | last post by:
We created a XML Schema that has nested table relations. We had the following Warning message come up. An unhandled exception of the type 'System.ArgumentException' occurred in system.data.dll...
1
by: Iain | last post by:
I've a fairly complex schema which I'm trying to create a typed data set for. I've had a number of issues to date but it is sort of working (e.g. elements are not considered nullable unless...
1
by: Jef De Rycke | last post by:
Hi access group, I have written code to create relations between tables according to a corresponding relations information table. At first I thought my code was not working properly because...
4
by: What-a-Tool | last post by:
I am trying to write a program that will take all the members of a data base, add them to a tree, with all child relations as sub-nodes. I am having a problem getting the parent child relations...
26
by: Allen Browne | last post by:
In Access 2000 and later, you can create a relation between tables where related records can be automatically set to Null rather than deleted when the primary record is deleted. I have not seen...
5
by: G .Net | last post by:
Hi I'm hoping that somebody can help me with a fairly puzzling problem. I've created some DataTables which have relations between them e.g. one to many. In the application, I want to remove...
9
by: Anil Gupte | last post by:
After reading a tutorial and fiddling, I finally got this to work. I can now put two tables created with a DataTable class into a DataRelation. Phew! And it works! Dim tblSliceInfo As New...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
0
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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
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...

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.