Command Button


N

Nora

In my form, "Form1" (which link to a query), there are 2 command buttons. 1
is to run the query and the other is to return to switchboard. When the query
runs, it open another form, "Form2" (which display the filtered record which
I entered in Form1), has 1 command button which closes Form2 (the active
form) and return to Form1 for another new query.

My problem now is whenever I'm back in Form1 to enter another new query, the
result in Form2 is blank. Why is this? How could I overcome this issue?

Thank you for your assistance.

Regards,
Nora
 
Ad

Advertisements

S

S.Clark

I don't understand, if you click form2.button1, then form2 closes. This
returns you to form1 to enter a new query. So, when you run a 2nd query,
then form2 opens with an empty set?
 
N

Nora

Dear Mr. S.Clark,


Thank you for responding to my clarification.

Yes, true what you have summarize or evaluate is correct.
Can you help me? Thanks.

BR,
Nor
 
S

S.Clark

What is the code used to Open form2 from form1?

What is the code used to close form2? There is a Save parameter with
prompt, no, & always. (if I remember correctly) What is that setting?
 
N

Nora

Here are the codes:-

Form1’s (“Find Tenderâ€)

Query Parameters
Name Type
Forms![Find Tender]!Code Text
Forms![Find Tender]!Part Text
Forms![Find Tender]![GQ No] Text

Code

1 VERSION 1.0 CLASS
2 BEGIN
3 MultiUse = -1 'True
4 END
5 Attribute VB_Name = "Form_Find Tender"
6 Attribute VB_GlobalNameSpace = False
7 Attribute VB_Creatable = True
8 Attribute VB_PredeclaredId = True
9 Attribute VB_Exposed = False
10 Option Compare Database
11 Option Explicit
12
13 Private Sub Command4_Click()
14 On Error GoTo Err_Command4_Click
15
16 Dim stDocName As String
17 Dim stLinkCriteria As String
18 Dim stLinkCriteria2 As String
19
20 stDocName = "Tender Record"
21
22 If IsNull([Part]) = True Then
23 stLinkCriteria = "
Code:
=" & "'" & Me![Code] & "'And[Reg No]=" &
"'" & Me![GQ No] & "'"
24	        DoCmd.OpenForm stDocName, , , stLinkCriteria
25	    Else
26	        stLinkCriteria2 = "[Code]=" & "'" & Me![Code] & "'And[Reg No]="
& "'" & Me![GQ No] &
"'And[Part]=" & "'" & Me![Part] & "'"
27	        DoCmd.OpenForm stDocName, , , stLinkCriteria2
28	    End If
29
30	Exit_Command4_Click:
31	    Exit Sub
32
33	Err_Command4_Click:
34	    MsgBox Err.Description
35	    Resume Exit_Command4_Click
36
37	End Sub


Form2’s (Tender Record)

On Click - Macro: Close And Open (Original)

Actions
Name	Condition	Action	Argument	Value
Close                 	Object Type: 	Form
Object Name: 	Tender Record
Save: 	Prompt
OpenForm         	Form Name: 	Find Tender
View: 	Form
Filter Name:
Where Condition:
Data Mode: 	-1
Window Mode: 	Normal
SetValue            	Item: 	[Forms]![Find Tender]![Code]
Expression: 		“â€
SetValue            	Item: 	[Forms]![Find Tender]![GQ No]
Expression: 		“â€
SetValue            	Item: 	[Forms]![Find Tender]![Part]
Expression: 		“â€
GoToControl      	Control Name: 	Code

Please evaluate. Thanks.

BR,
Nor
 
S

S.Clark

In the code, there are concatenations with AND. Ensure that there is a space
between the apostrophe and the AND and also between the AND and the [RegNo],
etc.

I would condense the code to more like this, too:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Tender Record"

If IsNull([Part]) = True Then
stLinkCriteria = "
Code:
=" & "'" & Me![Code] & "'And[Reg No]=" &
"'" & Me![GQ No] & "'"

Else
stLinkCriteria = "[Code]=" & "'" & Me![Code] & "'And[Reg No]=" &
"'" &
Me![GQ No] & "'And[Part]=" & "'" & Me![Part] & "'"

End If
debug.print stLinkCriteria 'use to show the criteria before the form
opens.
DoCmd.OpenForm stDocName, , , stLinkCriteria




[QUOTE="Nora"]
Here are the codes:-

Form1’s (“Find Tenderâ€)

Query Parameters
	Name	Type
	Forms![Find Tender]!Code	Text
	Forms![Find Tender]!Part	Text
	Forms![Find Tender]![GQ No]	Text

Code

	1	VERSION 1.0 CLASS
	2	BEGIN
	3	MultiUse = -1  'True
	4	END
	5	Attribute VB_Name = "Form_Find Tender"
	6	Attribute VB_GlobalNameSpace = False
	7	Attribute VB_Creatable = True
	8	Attribute VB_PredeclaredId = True
	9	Attribute VB_Exposed = False
	10	Option Compare Database
	11	Option Explicit
	12
	13	Private Sub Command4_Click()
	14	On Error GoTo Err_Command4_Click
	15
	16	    Dim stDocName As String
	17	    Dim stLinkCriteria As String
	18	    Dim stLinkCriteria2 As String
	19
	20	    stDocName = "Tender Record"
	21
	22	    If IsNull([Part]) = True Then
	23	        stLinkCriteria = "[Code]=" & "'" & Me![Code] & "'And[Reg No]=" &
"'" & Me![GQ No] & "'"
	24	        DoCmd.OpenForm stDocName, , , stLinkCriteria
	25	    Else
	26	        stLinkCriteria2 = "[Code]=" & "'" & Me![Code] & "'And[Reg No]="
& "'" & Me![GQ No] &
	"'And[Part]=" & "'" & Me![Part] & "'"
	27	        DoCmd.OpenForm stDocName, , , stLinkCriteria2
	28	    End If
	29
	30	Exit_Command4_Click:
	31	    Exit Sub
	32
	33	Err_Command4_Click:
	34	    MsgBox Err.Description
	35	    Resume Exit_Command4_Click
	36
	37	End Sub


Form2’s (Tender Record)

On Click - Macro: Close And Open (Original)

	Actions
	Name	Condition	Action	Argument	Value
	Close                 	Object Type: 	Form
	Object Name: 	Tender Record
	Save: 	Prompt
	OpenForm         	Form Name: 	Find Tender
	View: 	Form
	Filter Name:
	Where Condition:
	Data Mode: 	-1
	Window Mode: 	Normal
	SetValue            	Item: 	[Forms]![Find Tender]![Code]
	Expression: 		“â€
	SetValue            	Item: 	[Forms]![Find Tender]![GQ No]
	Expression: 		“â€
	SetValue            	Item: 	[Forms]![Find Tender]![Part]
	Expression: 		“â€
	GoToControl      	Control Name: 	Code

Please evaluate. Thanks.

BR,
Nor


[QUOTE="S.Clark"]
What is the code used to Open form2 from form1?

What is the code used to close form2?  There is a Save parameter with
prompt, no, & always. (if I remember correctly) What is that setting?
[/QUOTE][/QUOTE]
 
Ad

Advertisements

N

Nora

No changes. :(


S.Clark said:
In the code, there are concatenations with AND. Ensure that there is a space
between the apostrophe and the AND and also between the AND and the [RegNo],
etc.

I would condense the code to more like this, too:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Tender Record"

If IsNull([Part]) = True Then
stLinkCriteria = "
Code:
=" & "'" & Me![Code] & "'And[Reg No]=" &
"'" & Me![GQ No] & "'"

		    Else
		        stLinkCriteria = "[Code]=" & "'" & Me![Code] & "'And[Reg No]=" &
"'" &
			Me![GQ No] & "'And[Part]=" & "'" & Me![Part] & "'"

		    End If
		debug.print stLinkCriteria 'use to show the criteria before the form
opens.
		DoCmd.OpenForm stDocName, , , stLinkCriteria




[QUOTE="Nora"]
Here are the codes:-

Form1’s (“Find Tenderâ€)

Query Parameters
	Name	Type
	Forms![Find Tender]!Code	Text
	Forms![Find Tender]!Part	Text
	Forms![Find Tender]![GQ No]	Text

Code

	1	VERSION 1.0 CLASS
	2	BEGIN
	3	MultiUse = -1  'True
	4	END
	5	Attribute VB_Name = "Form_Find Tender"
	6	Attribute VB_GlobalNameSpace = False
	7	Attribute VB_Creatable = True
	8	Attribute VB_PredeclaredId = True
	9	Attribute VB_Exposed = False
	10	Option Compare Database
	11	Option Explicit
	12
	13	Private Sub Command4_Click()
	14	On Error GoTo Err_Command4_Click
	15
	16	    Dim stDocName As String
	17	    Dim stLinkCriteria As String
	18	    Dim stLinkCriteria2 As String
	19
	20	    stDocName = "Tender Record"
	21
	22	    If IsNull([Part]) = True Then
	23	        stLinkCriteria = "[Code]=" & "'" & Me![Code] & "'And[Reg No]=" &
"'" & Me![GQ No] & "'"
	24	        DoCmd.OpenForm stDocName, , , stLinkCriteria
	25	    Else
	26	        stLinkCriteria2 = "[Code]=" & "'" & Me![Code] & "'And[Reg No]="
& "'" & Me![GQ No] &
	"'And[Part]=" & "'" & Me![Part] & "'"
	27	        DoCmd.OpenForm stDocName, , , stLinkCriteria2
	28	    End If
	29
	30	Exit_Command4_Click:
	31	    Exit Sub
	32
	33	Err_Command4_Click:
	34	    MsgBox Err.Description
	35	    Resume Exit_Command4_Click
	36
	37	End Sub


Form2’s (Tender Record)

On Click - Macro: Close And Open (Original)

	Actions
	Name	Condition	Action	Argument	Value
	Close                 	Object Type: 	Form
	Object Name: 	Tender Record
	Save: 	Prompt
	OpenForm         	Form Name: 	Find Tender
	View: 	Form
	Filter Name:
	Where Condition:
	Data Mode: 	-1
	Window Mode: 	Normal
	SetValue            	Item: 	[Forms]![Find Tender]![Code]
	Expression: 		“â€
	SetValue            	Item: 	[Forms]![Find Tender]![GQ No]
	Expression: 		“â€
	SetValue            	Item: 	[Forms]![Find Tender]![Part]
	Expression: 		“â€
	GoToControl      	Control Name: 	Code

Please evaluate. Thanks.

BR,
Nor


[QUOTE="S.Clark"]
What is the code used to Open form2 from form1?

What is the code used to close form2?  There is a Save parameter with
prompt, no, & always. (if I remember correctly) What is that setting?

:

Dear Mr. S.Clark,


Thank you for responding to my clarification.

Yes, true what you have summarize or evaluate is correct.
Can you help me? Thanks.

BR,
Nor


:

I don't understand, if you click form2.button1, then form2 closes.  This
returns you to form1 to enter a new query.  So, when you run a 2nd query,
then form2 opens with an empty set?

:

In my form, "Form1" (which link to a query), there are 2 command buttons. 1
is to run the query and the other is to return to switchboard. When the query
runs, it open another form, "Form2" (which display the filtered record which
I entered in Form1), has 1 command button which closes Form2 (the active
form) and return to Form1 for another new query.

My problem now is whenever I'm back in Form1 to enter another new query, the
result in Form2 is blank. Why is this? How could I overcome this issue?

Thank you for your assistance.

Regards,
Nora[/QUOTE][/QUOTE][/QUOTE]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Command Button 0
Command Button 5
command buttons 2
Command Button 2
command button 2
Command Buttons 0
Command Button 2
Command Button 3

Top