If Statement In My Query

S

SunflowerdBGirl

I have a query that I've designed to open a form and just display one
project's information. The user has a form in which they select the project
from a list box that they want to see and then that selection goes to my
query. If that project has not had any information entered against it I need
the form to start a new record using the project selected in my combo box
that prompts the query in the where clause.

SELECT tblCheckbookLog.Date, tblCheckbookLog.Project,
tblCheckbookLog.TransType, tblCheckbookLog.PRNum, tblCheckbookLog.AY,
tblCheckbookLog.PD, tblCheckbookLog.PV, tblCheckbookLog.RE,
tblCheckbookLog.FV, tblCheckbookLog.Obj, tblCheckbookLog.Description,
tblCheckbookLog.Withdrawl, tblCheckbookLog.Deposit,
tblCheckbookLog.AwaitingSigs, tblCheckbookLog.ToRBMD,
tblCheckbookLog.ToPrimavera, tblCheckbookLog.FinalAmt, tblProjects.Office,
tblCheckbookLog.PersonnelName, tblCheckbookLog.Comments,
tblCheckbookLog.VendorName, tblCheckbookLog.TSSElement,
tblCheckbookLog.Category
FROM tblProjects INNER JOIN tblCheckbookLog ON tblProjects.ProjId =
tblCheckbookLog.Project
WHERE (((tblCheckbookLog.Project)=[Forms]![frmProjSelect]![cboProject]));

Any suggestions? I was thinking an If statement but I have no idea how to
say if no records exist create a new one.
 
D

Duane Hookom

If the form is opened in edit mode an allows data entry of new records, set
the default of the Project field to Forms!frmProjSelect!cobProject.
 
S

SunflowerdBGirl

Thank you so much. This worked like a charm! You just saved me so much work.

Duane Hookom said:
If the form is opened in edit mode an allows data entry of new records, set
the default of the Project field to Forms!frmProjSelect!cobProject.

--
Duane Hookom
Microsoft Access MVP


SunflowerdBGirl said:
I have a query that I've designed to open a form and just display one
project's information. The user has a form in which they select the project
from a list box that they want to see and then that selection goes to my
query. If that project has not had any information entered against it I need
the form to start a new record using the project selected in my combo box
that prompts the query in the where clause.

SELECT tblCheckbookLog.Date, tblCheckbookLog.Project,
tblCheckbookLog.TransType, tblCheckbookLog.PRNum, tblCheckbookLog.AY,
tblCheckbookLog.PD, tblCheckbookLog.PV, tblCheckbookLog.RE,
tblCheckbookLog.FV, tblCheckbookLog.Obj, tblCheckbookLog.Description,
tblCheckbookLog.Withdrawl, tblCheckbookLog.Deposit,
tblCheckbookLog.AwaitingSigs, tblCheckbookLog.ToRBMD,
tblCheckbookLog.ToPrimavera, tblCheckbookLog.FinalAmt, tblProjects.Office,
tblCheckbookLog.PersonnelName, tblCheckbookLog.Comments,
tblCheckbookLog.VendorName, tblCheckbookLog.TSSElement,
tblCheckbookLog.Category
FROM tblProjects INNER JOIN tblCheckbookLog ON tblProjects.ProjId =
tblCheckbookLog.Project
WHERE (((tblCheckbookLog.Project)=[Forms]![frmProjSelect]![cboProject]));

Any suggestions? I was thinking an If statement but I have no idea how to
say if no records exist create a new one.
 
Top