Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Listbox doesn't open to a new (blank) record when form opens for new record input

Posted on 2011-03-04
7
449 Views
Last Modified: 2013-11-05
I have a form that opend for a new record input.  On this form is a listbox.  But when the form opens the listbox is not empty and should be.  What is wrong with my code... ?...

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "frmProject"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    DoCmd.GoToRecord , , acNewRec
    Forms!frmProject.List136.Requery
    Forms!frmProject.txtDrops = ""
    Forms!frmProject.txtJobN.SetFocus

Exit_Command12_Click:
    Exit Sub

Err_Command12_Click:
    MsgBox Err.Description
    Resume Exit_Command12_Click
0
Comment
Question by:SteveL13
  • 3
  • 3
7 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 35037838
What is the rowsource of the listbox?
0
 

Author Comment

by:SteveL13
ID: 35038039
Is a query... Here is the SQL code:

SELECT Format([tblProjectDetail].[DetailID],"0") AS [Drop], tblProjectDetail.JobN, Format([tblProjectDetail].[Qty],"0") AS Qty, tblProjectDetail.DropDueDate AS [Due Date], tblProjectDetail.Complete, tblProjectDetail.Billed, tblProjectDetail.Name, tblProjectDetail.Cancelled
FROM tblProjectDetail
WHERE (((tblProjectDetail.JobN)=[Forms]![frmProject]![txtJobN]))
ORDER BY tblProjectDetail.Complete DESC , tblProjectDetail.DropDueDate;
0
 
LVL 77

Expert Comment

by:peter57r
ID: 35038926
I don't understand why you are not getting an error.

Does txtJobN have a default value?
0
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 

Author Comment

by:SteveL13
ID: 35038950
No it does not.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35059117
Perhaps you should take a step back and explain exactly what this system is supposed to be doing...?
0
 

Author Comment

by:SteveL13
ID: 35096225
When I open the form for a new record entry, the lisbox on that form should be empty.  
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 35096651
I suspect there is more to this problem than is apparent here.
But a simple fix should be..

WHERE (((tblProjectDetail.JobN)=nz([Forms]![frmProject]![txtJobN], ""))
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question