Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 481
  • Last Modified:

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

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
SteveL13
Asked:
SteveL13
  • 3
  • 3
1 Solution
 
peter57rCommented:
What is the rowsource of the listbox?
0
 
SteveL13Author Commented:
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
 
peter57rCommented:
I don't understand why you are not getting an error.

Does txtJobN have a default value?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
SteveL13Author Commented:
No it does not.
0
 
Jeffrey CoachmanCommented:
Perhaps you should take a step back and explain exactly what this system is supposed to be doing...?
0
 
SteveL13Author Commented:
When I open the form for a new record entry, the lisbox on that form should be empty.  
0
 
peter57rCommented:
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

Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now