Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can a query display a message through sql??? thanks 1

Status
Not open for further replies.

greekpatriott

Technical User
Dec 15, 2004
65
0
0
CY
Hello,
If I have a query with the following sql:
INSERT INTO T_ProjectPhases ( ProjectNo, Phase, PhaseDescription, Item )
SELECT Forms!Switchboard!Active_ContractNo.Caption AS ProjectNo, T_ProjectPhases.Phase, T_ProjectPhases.PhaseDescription, T_ProjectPhases.Item
FROM T_ProjectPhases
GROUP BY T_ProjectPhases.Phase, T_ProjectPhases.PhaseDescription, T_ProjectPhases.Item, T_ProjectPhases.ProjectNo
HAVING (((T_ProjectPhases.ProjectNo) Like [Enter ProjectNo to Copy From:]));

Can this query display a message "Please insert a Project No first in the switchboard"

The second question is:
When I cancel a macro from running I get an action failed with an option to press HALT. Is there a way to modify this?
Thanks in advance.

 
You can sort of fake it but you really need to handle something like that with VB code as in
Code:
If Len(Forms!Switchboard!Active_ContractNo.Caption) = 0 Then
   MsgBox "You MUST Enter the Project Number on the Switch Board"
Else
   [COLOR=green]' Run the INSERT SQL[/color]
End If
 
Hmmmmm I dont get it. I did not manage to make the code work. Can you be a bit more specific about the procedure??? Cheers
 
This is my code What am I doing wrong? Can anyone help out? Cheers. I dont seem to get the message.

Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
If Forms!Switchboard!Active_ContractNo.Caption = Null Then
MsgBox "You MUST Enter the Project Number on the Switch Board"
Else
Dim stDocName As String
stDocName = "Query1"
DoCmd.OpenQuery stDocName, acNormal, acEdit
End If
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
 
I also used this substitution but also no luck
If Len(Forms!Switchboard!Active_ContractNo.Caption) = 0 Then
 
Ok I found the mistake. I had a caption * in the Active_ContractNo properties. Now it works. Thanks Golom (Programmer). I used your code with few additions. Cheers.

Here is the final code.
Private Sub Command1_Click()
On Error GoTo Err_Command1_Click
If Len(Forms!Switchboard!Active_ContractNo.Caption) = 0 Then
MsgBox "You MUST Enter the Project Number on the Switch Board"
Else
Dim stDocName As String
stDocName = "Query1"
DoCmd.OpenQuery stDocName, acNormal, acEdit
End If
Exit_Command1_Click:
Exit Sub
Err_Command1_Click:
MsgBox Err.Description
Resume Exit_Command1_Click
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top