On the combo problem

I want to make a form, there are two combo form
There are two corresponding tables A and B as shown in Figure

The two tables in the XX name (1, 2, 3) is the same. I want to realize the XX name Combo1 (1), showed only YY name in combo2 (1, 2), select the XX name Combo1 (2), showed only YY name in combo2 (3, 4), this can do, please pointing. Because the rookie, please, thank you.

Started by Ingram at December 14, 2016 - 9:49 PM

The COMBO1 property is set:
COLUMNCOUNT=1
The ROWSOURCE=[table A]
ROWSOURCETYPE=2
Write code in the form of COMBO1 CLICK event:
SELECT * FROM B WHERE ALLTRIM (XX name) ==ALLTRIM(THISFORM.COMBO1.VALUE) INTO CURSOR T
WITH THISFORM.COMBO2
.COLUMNCOUNT=2
.ROWSOURCE=[T]
.ROWSOURCETYPE=2
ENDWITH
Write code in the form of COMBO2 CLICK event:
THISFORM.COMBO2.DISPLAYVALUE=THISFORM.COMBO2.LIST(THISFORM.COMBO2.LISTINDEX,2)

Posted by James at December 15, 2016 - 10:28 PM

In first the Combobox control's InteractiveChange event plus code
If !Empty(Alltrim(This.DisplayValue))
Thisform.COMBO2.RowSource=Null
Select YY Into Cursor cTable1 From table name B Where Alltrim (XX name) =Alltrim (This.DisplayValue) Order By YY name
Thisform.COMBO2.RowSource='The cTable1.yy name'
Endif

Posted by Perry at December 21, 2016 - 10:51 PM

Plus
Thisform.COMBO2.RowSourcetype=6

Posted by Elton at January 05, 2017 - 11:01 PM

First of all thank ten beans three teachers, ComboBox control problem is solved, but the form of the "save" button code failed, that is after the operation that form did not choose combo2 field, This is how to return a responsibility, I the "save" button code as follows (before the code above does not add to the normal operation)
Set Date YMD
Set Century On
Set Mark To "-"
xm=alltrim(thisform.combo1.value)
yshkmch=alltrim(thisform.combo2.value)
shxblsh=alltrim(thisform.Text1.value)
shxnbsh=ALLTRIM(thisform.text2.Value)
shxjdsh=ALLTRIM(thisform.text3.Value)
zhxblsh=ALLTRIM(thisform.text4.Value)
zhxnbsh=alltrim(thisform.Text5.value)
zhxjdsh=ALLTRIM(thisform.text6.Value)
xxblsh=ALLTRIM(thisform.text7.Value)
xxnbsh=ALLTRIM(thisform.text8.Value)
xxjdsh=alltrim(thisform.Text9.value)
yshshj=thisform.text10.Value
if empty(xm)
messagebox("Select the name of towns ", 16," the system prompts")
return
else
endif
if empty(yshkmch)
messagebox("Please select a diversion port name ", 16," the system prompts")
return
else
endif
if empty(yshshj)
messagebox("Please enter a diversion time ", 16," the system prompts")
return
else
endif
*if empty(yshshj)
* messagebox("Please enter a diversion time ", 16," the system prompts")
* return
* else
* Locate for diversion time =CToD(ALLTRIM(thisform.Text10.value))
* if .not.eof()
* go top
* messagebox("Do not allow duplicate diversion time ", 16," the system prompts")
* thisform.Text10.setfocus
* return
* endif
* endif
if empty(shxblsh)
messagebox("Please enter the early ", 16," the proportion of water system prompt")
return
else
endif
if empty(shxnbsh)
messagebox("Please enter the water ", 16 early," the system prompts")
return
else
endif
if empty(shxjdsh)
messagebox("Please enter the early ", 16," motorized water system prompt")
return
else
endif
if empty(zhxblsh)
messagebox("Please enter the mid water ", 16," the proportion of the system prompt")
return
else
endif
if empty(zhxnbsh)
messagebox("Please enter the mid water ", 16," the system prompts")
return
else
endif
if empty(zhxjdsh)
messagebox("Please enter the mid motor water ", 16," the system prompts")
return
else
endif
if empty(xxblsh)
messagebox("Please enter the late ", 16," the proportion of water system prompt")
return
else
endif
if empty(xxnbsh)
messagebox("Please enter the water ", 16 late," the system prompts")
return
else
endif
if empty(xxjdsh)
messagebox("Please enter the late ", 16 motorized water," the system prompts")
return
else
endif
msg=messagebox('Sure you want to save the record? ', 32+4, "the system prompts")
if msg=6
INSERT INTO diversion water (Xiang, diversion port name, the proportion of water inside the water early early, early, mid water, motorized water, water, internal mid late mid motorized water ratio, water, water inside late late, motorized water diversion, time);
VALUES(alltrim(thisform.combo1.value),;
alltrim(thisform.combo2.value),;
alltrim(thisform.Text1.value),;
ALLTRIM(thisform.text2.Value),;
alltrim(thisform.Text3.value),;
ALLTRIM(thisform.text4.Value),;
alltrim(thisform.Text5.value),;
ALLTRIM(thisform.text6.Value),;
alltrim(thisform.Text7.value),;
ALLTRIM(thisform.text8.Value),;
ALLTRIM(thisform.text9.Value),;
ctod(ALLTRIM(thisform.Text10.value)))
thisform.grid1.Refresh
GO bottom
thisform.combo1.SetFocus
thisform.combo1.Value=""
thisform.combo2.Value=""
thisform.Text1.value=""
thisform.Text2.value=""
thisform.text3.Value=""
thisform.text4.Value=""
thisform.Text5.value=""
thisform.Text6.value=""
thisform.text7.Value=""
thisform.text8.Value=""
thisform.text9.Value=""
thisform.text10.Value=""
thisform.Refresh
ENDIF
Then, the code red second conditional statements can not operate normally, you help me, thank you.

Posted by Ingram at January 05, 2017 - 11:46 PM

xm=alltrim(thisform.combo1.value)
yshkmch=alltrim(thisform.combo2.value)

Instead of
xm=alltrim(thisform.combo1.DisplayValue)
yshkmch=alltrim(thisform.combo2.DisplayValue)

Posted by Perry at January 07, 2017 - 11:11 PM