473,385 Members | 2,003 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,385 software developers and data experts.

Making null a higher number

Hello,

I am tring to do a sort in a form where there are numbers from 1 to 10. There is also a lot of nulls in there as well. When I sort them from 1 to 10, the nulls are first. Is there a way to make the nulls come after 10?

Let me know either the code to make it equal like 11 or how to make it show them last.

Thanks,

Brian Smith
Oct 11 '07 #1
22 1433
Rabbit
12,516 Expert Mod 8TB
Nz(Value, ValueIfNull)

So:
Expand|Select|Wrap|Line Numbers
  1. Nz(Field1, 99)
  2.  
All nulls will have the value 99.
Oct 11 '07 #2
After I entered that code, I get a "compile error: Expected:=" Message This is what I put in the code as:

Private Sub Priority_Click()
Nz (Priority,99)
End Sub

Do I need to do something diffrent? Let me know.

Brian Smith
Oct 15 '07 #3
Rabbit
12,516 Expert Mod 8TB
You have to use a query to convert and order the records and use that as the record source for the form.
Oct 15 '07 #4
I guess I'm not sure how I would do that. I made a querry, but I can't get the nulls to come after 10.
Oct 16 '07 #5
Rabbit
12,516 Expert Mod 8TB
What's the query you used?
Oct 16 '07 #6
I made a querry to pull all the information out of the table. I tried the Nz in the criteria, but it doesn't work there. everytime I do a sort, it doesn't show any information in my form or in the querry.
Oct 16 '07 #7
Rabbit
12,516 Expert Mod 8TB
No, I meant what's the SQL you used? In query design view, right click the title bar and click SQL View.
Oct 16 '07 #8
Sorry, I didn't know that.
Expand|Select|Wrap|Line Numbers
  1. SELECT Issues.[Issue Index], Issues.[Product Line], Issues.[Product(s)], Issues.Feature, Issues.[Conditions of Occurrence], Issues.Resolution, Issues.[Problem Description], Issues.[Problem nickname], Issues.Importance, Issues.Priority, Issues.Owner, Issues.Status, Issues.[Issue Type], Issues.[Fike part #], Issues.[Product Version(s)], Issues.[Found By], Issues.[Date Found], Issues.[Initial Fike Contact], Issues.[Date Entered], Issues.[Date Started], Issues.[Date Completed], Issues.[Completed By], Issues.[Completion Verified By], Issues.[Product version issue resolved in], Issues.Hyperlink, Issues.Notes
  2. FROM Issues;
  3.  
Priority is the one I need to sort with the nulls after 10.
Oct 16 '07 #9
Rabbit
12,516 Expert Mod 8TB
Sorry, I didn't know that.
Expand|Select|Wrap|Line Numbers
  1. SELECT Issues.[Issue Index], Issues.[Product Line], Issues.[Product(s)], Issues.Feature, Issues.[Conditions of Occurrence], Issues.Resolution, Issues.[Problem Description], Issues.[Problem nickname], Issues.Importance, Issues.Priority, Issues.Owner, Issues.Status, Issues.[Issue Type], Issues.[Fike part #], Issues.[Product Version(s)], Issues.[Found By], Issues.[Date Found], Issues.[Initial Fike Contact], Issues.[Date Entered], Issues.[Date Started], Issues.[Date Completed], Issues.[Completed By], Issues.[Completion Verified By], Issues.[Product version issue resolved in], Issues.Hyperlink, Issues.Notes
  2. FROM Issues;
  3.  
Priority is the one I need to sort with the nulls after 10.
I thought you said you used Nz? I don't see it in there.
Expand|Select|Wrap|Line Numbers
  1. SELECT Issues.[Issue Index], Issues.[Product Line], Issues.[Product(s)], Issues.Feature, Issues.[Conditions of Occurrence], Issues.Resolution, Issues.[Problem Description], Issues.[Problem nickname], Issues.Importance, Issues.Priority, Issues.Owner, Issues.Status, Issues.[Issue Type], Issues.[Fike part #], Issues.[Product Version(s)], Issues.[Found By], Issues.[Date Found], Issues.[Initial Fike Contact], Issues.[Date Entered], Issues.[Date Started], Issues.[Date Completed], Issues.[Completed By], Issues.[Completion Verified By], Issues.[Product version issue resolved in], Issues.Hyperlink, Issues.Notes, Nz([Priority], 99) AS NewPriority
  2. FROM Issues
  3. ORDER BY Nz([Priority], 99);
Oct 16 '07 #10
I didn't know where to put Nz, and where I put it caused problems so I deleted it. Now that shows the order in the form with 1 then 10 then 2, and s on. I also want it to be ordered this way everytime I open the form. I would like to do the sort either by hitting the sort assending button, or creatting one. Is this possible?
Oct 16 '07 #11
Rabbit
12,516 Expert Mod 8TB
The reason it's ordering it 1, 10, 2 ... is because the field is text. If you want to order it 1,2,3, ... then you need to change your field to numeric or use a query to create a numeric column.

Yes, you can create a button that will sort your records. You'll have to use the OrderBy and OrderByOn properties of the form.
Oct 16 '07 #12
Can you please give me an example of what it would look like in VB?
Oct 16 '07 #13
Rabbit
12,516 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. Me.OrderBy = "NewPriority"
  2. Me.OrderByOn = True
  3.  
Oct 16 '07 #14
Scott Price
1,384 Expert 1GB
Also, Brian, just for information. The title of the thread makes it appear that you are assuming Null to be a number. Null is not a number! Please read through this article: What is Null? for more information.

Regards,
Scott
Oct 17 '07 #15
Thanks for the information Scott.

I still can't get it to work. Let me see if I can explain this a little better. My engineer would like to apply some filters to a form. Then he would like to sort the Priority ascending to show 1 first and null after 10. If I do this with a query, the filter of the form changes the query, so I need to be able to do this with a button on the form. I have tried several things including your suggestions, but I am unable to get it to work.

Thanks for bearing with me.

Brian
Oct 17 '07 #16
Rabbit
12,516 Expert Mod 8TB
Thanks for the information Scott.

I still can't get it to work. Let me see if I can explain this a little better. My engineer would like to apply some filters to a form. Then he would like to sort the Priority ascending to show 1 first and null after 10. If I do this with a query, the filter of the form changes the query, so I need to be able to do this with a button on the form. I have tried several things including your suggestions, but I am unable to get it to work.

Thanks for bearing with me.

Brian
Post number 14 should work.
Oct 17 '07 #17
When I put both the query like you mentioned, and put the VB code in, it comes up "Enter Parameter Value" "NewPriority" empty space to enter, ok and cancel. How do I do this?
Oct 18 '07 #18
Rabbit
12,516 Expert Mod 8TB
Table1
ValueField; Text

Query1
Expand|Select|Wrap|Line Numbers
  1. SELECT Val(Nz(ValueField, 99)) AS NoNulls, Val(ValueField) AS WithNulls
  2. FROM Table1;
  3.  
Report1
Record Source = Query1
but_Sort
but_Unsort
Expand|Select|Wrap|Line Numbers
  1. Private Sub but_Sort_Click()
  2.    Me.OrderBy = "NoNulls"
  3.    Me.OrderByOn = True
  4. End Sub
  5.  
  6. Private Sub but_Unsort_Click()
  7.    Me.OrderBy = "WithNulls"
  8.    Me.OrderByOn = True
  9. End Sub
  10.  
Oct 18 '07 #19
I guess I can't do what I want, or I'm not explaining it good enough. Thanks for your help and patients.
Oct 18 '07 #20
Rabbit
12,516 Expert Mod 8TB
What I laid out should work.
I created the table, the query, and the form. Then I applied a filter to the form. And I clicked the button on the form to sort with the nulls at the end.
Oct 18 '07 #21
OHH! I figured it out what I did wrong. It works great thanks a bunch.
Oct 18 '07 #22
Rabbit
12,516 Expert Mod 8TB
Not a problem, good luck.
Oct 18 '07 #23

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

Similar topics

1
by: Kenneth McDonald | last post by:
I'm working on the 0.8 release of my 'rex' module, and would appreciate feedback, suggestions, and criticism as I work towards finalizing the API and feature sets. rex is a module intended to make...
7
by: MarkNeumann | last post by:
I'm coming from a Corel paradox background and moving into an Access environment. So I'm struggling with something that I think is probably way simpler than I'm making it out to be. Access 2007...
9
by: tiwarinitin.3108 | last post by:
An interactive program that reads 3 list of numbers, which are stored in three seperate files, and creates one sorted list. Each file should contain not more than 15 numbers.
204
by: Masood | last post by:
I know that this topic may inflame the "C language Taleban", but is there any prospect of some of the neat features of C++ getting incorporated in C? No I am not talking out the OO stuff. I am...
1
by: Gomi | last post by:
Hi guys I'm new to C++ Programming and I am having trouble in making my Guessing game code replay. I am suppose to give the user that is playing my game the opportunity to play again with options of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: 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
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.