473,378 Members | 1,621 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

combo box drop down value is repeating

143 100+
Hello everyone..

i have a small problem here... i have a combobox in my project call cmbresult which has been filled up in the properties by using list properties... i have 4 option there... whn i add a new record its fine and by clicking the drop down the 4 option is showing and i can select and add easily bt when i want to view any selected record whtever has been set for the cmbresult its repeating 2 times... i have tried to use the set focus and get focus bt its not working...
can anyone help me here?
thank u very much
Feb 5 '09 #1
5 2317
debasisdas
8,127 Expert 4TB
i am not sure what exactly is your problem . please post the code that youare working on.
Feb 5 '09 #2
squrel
143 100+
Ok here is my code which i m working on it.... plz help me.. my cmbresult is getting repeated which i m using the viewall button.. the cmbresult has been filled from the list properties
thank u very much


Expand|Select|Wrap|Line Numbers
  1.  
  2. Option Explicit
  3. Private Sub Form_Initialize()
  4.  On Error GoTo ChkErr
  5.         Db.Close
  6.         Db.ConnectionString = pStrConnectionString
  7.         Db.ConnectionTimeout = 0
  8.         Db.Open
  9.         Db.CursorLocation = adUseClient
  10.         DoEvents
  11. Exit Sub
  12. ChkErr:
  13.     If Err.Number > 0 Then
  14.     MsgBox Err.Number & vbNewLine & Err.Description
  15.                Call ErrHand(Me.Caption, "Form_Initialize")
  16.         'Resume Next
  17.     End If
  18. End Sub
  19. Private Sub Form_Load()
  20. On Error GoTo ChkErr
  21.      FormUpdateSQL1.ConnectionString = pStrConnectionString
  22.     FormUpdateSQL1.TableName = "Proceedings"
  23.     FormUpdateSQL1.FieldList = "Id;Description;CourtId;CaseId;AdvId;PersonAttend;Result;Nextdt;Reminddt;Advname;"
  24.     FormUpdateSQL1.ControlList = "txtId;txtDescription;txtCourtId;txtCaseId;txtAdvocateId;txtPerson;cmbresult;DTPnextdt;DTPreminddt;txtadvocate;"
  25.     FormUpdateSQL1.ViewFields = "Id;Description;CourtId;CaseId;AdvId;PersonAttend;Result;Nextdt;Reminddt;Advname;"
  26.     FormUpdateSQL1.FormatString = "Id;Description;CourtId;CaseId;AdvId;PersonAttend;Result;Nextdt;Reminddt;Advname;"
  27.     FormUpdateSQL1.DoVisible 4, False
  28.     FormUpdateSQL1.DoVisible 6, False
  29.     FormUpdateSQL1.DoVisible 8, False
  30.     FormUpdateSQL1.AllowEdit = True
  31.     FormUpdateSQL1.Refresh
  32.     'cmbResult.Enabled = False
  33.     cmbcaseId.Enabled = False
  34.     cmbcourtid.Enabled = False
  35.     cmbadvocateid.Enabled = False
  36.     Call Grid_Data
  37. Exit Sub
  38. ChkErr:
  39. If Err.Number > 0 Then
  40. MsgBox Err.Number & vbNewLine & Err.Description
  41.            Call ErrHand("frmProceedings", "Form_Load")
  42.     'Resume Next
  43. End If
  44.  
  45. Grid_Data
  46. End Sub
  47. Private Sub cmbCaseId_Click()
  48. txtcaseid.Text = GetCorrespodingField("casemaster", "caseid", "CaseId", cmbcaseId, False)
  49. End Sub
  50. Private Sub cmbCaseId_GotFocus()
  51. Call fillcombo("casemaster", "CaseId", cmbcaseId, , True)
  52. End Sub
  53. Private Sub cmbCaseId_LostFocus()
  54. If cmbcaseId.Text = "" Then
  55.     txtcaseid.Text = ""
  56. End If
  57. End Sub
  58.  
  59. Private Sub txtCaseId_Change()
  60. 'If txtparty.Text = "" Then
  61.     cmbcaseId.Text = GetCorrespodingField("casemaster", "CaseId", "caseid", txtcaseid, False)
  62.     'Call Grid_Data
  63.    'End If
  64. End Sub
  65. Public Function fill()
  66.     Dim Rs       As New ADODB.Recordset
  67.     Dim i       As Integer
  68.  
  69.     If Rs.State = adStateOpen Then Rs.Close
  70.         Rs.Open ("select Distinct proceedings.CaseId From proceedings, casemaster where casemaster.CaseId = '" & txtcaseid.Text & "' and proceedings.caseid = casemaster.caseid"), Db, adOpenKeyset, adLockPessimistic
  71.         'select Distinct caseclaims.CaseId from CaseClaims,casemaster where casemaster.CaseId = '" & txtcaseid.Text & "' and caseclaims.caseid = casemaster.caseid"), Db, adOpenKeyset, adLockPessimistic
  72.         ', MsVendors Ven,TxPoHdr Hdr Where Hdr.VendorId = '" & txtVendorId.Text & "' And Hdr.UnitId = Unit.UnitId and Hdr.YY = " & FinancialYear & " "), Db, adOpenKeyset, adLockPessimistic
  73.  
  74.     vCombo = ""
  75.     cmbcaseId = ""
  76.     cmbcaseId.Clear
  77.     vCombo = cmbcaseId.Text
  78.  
  79. '    If Clear Then Cmb.Clear
  80.     i = 0
  81.     While Not Rs.EOF
  82.         If Rs.Fields(0) <> "" Then
  83.             cmbcaseId.AddItem Rs.Fields(0)
  84.             If Rs.Fields(0) = vCombo Then cmbcaseId.ListIndex = i
  85.             i = i + 1
  86.         End If
  87.         Rs.MoveNext
  88.     Wend
  89.     Rs.Close
  90.  
  91. End Function
  92.  
  93. Private Sub cmbCourtId_Click()
  94. Dim Rs       As New ADODB.Recordset
  95. txtcourtid.Text = GetCorrespodingField("court", "Courtid", "courtid", cmbcourtid, False)
  96. 'Dim cn As String
  97. 'Dim COURTID As Integer
  98. 'If cmbCourtId.Text <> -1 Then
  99. 'If Rs.State = adStateOpen Then Rs.Close
  100. 'Rs.Open ("select courtname from court where courtid = '" & cmbCourtId.Text & "'"), Db, adOpenDynamic, adLockOptimistic
  101. 'cn = Rs.Fields(COURTID).Value
  102. 'Text1.Text = cn
  103. 'Text1.Refresh
  104. 'End If
  105. End Sub
  106. Private Sub cmbCourtId_GotFocus()
  107. Call fillcombo("casemaster", "CourtId", cmbcourtid, , True)
  108. End Sub
  109. Private Sub cmbCourtId_LostFocus()
  110. If cmbcourtid.Text = "" Then
  111.     txtcourtid.Text = ""
  112. End If
  113. End Sub
  114. Private Sub txtCourtId_Change()
  115. 'If txtCourtId.Text = "" Then
  116.     cmbcourtid.Text = GetCorrespodingField("court", "CourtId", "CourtId", txtcourtid, False)
  117.     'Call Grid_Data
  118.    'End If
  119. End Sub
  120. Public Function fillCourtId()
  121.     Dim Rs       As New ADODB.Recordset
  122.     Dim i       As Integer
  123.  
  124.     If Rs.State = adStateOpen Then Rs.Close
  125.         Rs.Open ("select Distinct proceedings.CourtId From proceedings, casemaster where casemaster.Courtid = '" & txtcourtid.Text & "' and casemaster.Courtid = proceedings.Courtid"), Db, adOpenKeyset, adLockPessimistic
  126.         'select Distinct court.courtid from  court,casemaster,party where casemaster.PartyId = '" & txtpartyId.Text & "' And casemaster.courtid = court.courtid"), Db, adOpenKeyset, adLockPessimistic
  127.         '"select Distinct courtid from  court,casemaster Where casemaster.partytype = '" & txtParty.Text & "'  And casemaster.courtid= court.courtid "), Db, adOpenKeyset, adLockPessimistic
  128.  
  129.     vCombo = ""
  130.     cmbcourtid = ""
  131.     cmbcourtid.Clear
  132.     vCombo = cmbcourtid.Text
  133.  
  134. '    If Clear Then Cmb.Clear
  135.     i = 0
  136.     While Not Rs.EOF
  137.         If Rs.Fields(0) <> "" Then
  138.             cmbcourtid.AddItem Rs.Fields(0)
  139.             If Rs.Fields(0) = vCombo Then cmbcourtid.ListIndex = i
  140.             i = i + 1
  141.         End If
  142.         Rs.MoveNext
  143.     Wend
  144.     Rs.Close
  145. End Function
  146. Private Sub Form_KeyPress(KeyAscii As Integer)
  147. If KeyAscii = 13 Then
  148.     SendKeys "{Tab}"
  149. End If
  150. End Sub
  151. Private Sub cmbAdvocateid_Click()
  152. Dim Rs       As New ADODB.Recordset
  153. txtadvocateid.Text = GetCorrespodingField("advocate", "advid", "advid", cmbadvocateid, False)
  154. Dim cn As String
  155. Dim advID As Integer
  156. If cmbadvocateid.Text <> -1 Then
  157. If Rs.State = adStateOpen Then Rs.Close
  158. Rs.Open ("select advname from advocate where advid = '" & cmbadvocateid.Text & "'"), Db, adOpenDynamic, adLockOptimistic
  159. cn = Rs.Fields(advID).Value
  160. txtadvocate.Text = cn
  161. txtadvocate.Refresh
  162. End If
  163. End Sub
  164. Private Sub cmbadvocateId_GotFocus()
  165. Call fillcombo("advocate", "advId", cmbadvocateid, , True)
  166. End Sub
  167. Private Sub cmbadvocateId_LostFocus()
  168. If cmbadvocateid.Text = "" Then
  169.     txtadvocateid.Text = ""
  170. End If
  171. End Sub
  172. Private Sub txtadvocateId_Change()
  173. 'If txtCourtId.Text = "" Then
  174.     cmbadvocateid.Text = GetCorrespodingField("advocate", "advid", "advId", txtadvocateid, False)
  175.     'Call Grid_Data
  176.    'End If
  177. End Sub
  178. Public Function filladvocateId()
  179.     Dim Rs       As New ADODB.Recordset
  180.     Dim i       As Integer
  181.  
  182.     If Rs.State = adStateOpen Then Rs.Close
  183.         Rs.Open ("select Distinct advocate.advId From advocate,proceedings where proceedings.advid = '" & txtadvocateid.Text & "' and advocate.advid = proceedings.advid"), Db, adOpenKeyset, adLockPessimistic
  184.         'select Distinct court.courtid from  court,casemaster,party where casemaster.PartyId = '" & txtpartyId.Text & "' And casemaster.courtid = court.courtid"), Db, adOpenKeyset, adLockPessimistic
  185.         '"select Distinct courtid from  court,casemaster Where casemaster.partytype = '" & txtParty.Text & "'  And casemaster.courtid= court.courtid "), Db, adOpenKeyset, adLockPessimistic
  186.  
  187.     vCombo = ""
  188.     cmbadvocateid = ""
  189.     cmbadvocateid.Clear
  190.     vCombo = cmbadvocateid.Text
  191.  
  192. '    If Clear Then Cmb.Clear
  193.     i = 0
  194.     While Not Rs.EOF
  195.         If Rs.Fields(0) <> "" Then
  196.             cmbadvocateid.AddItem Rs.Fields(0)
  197.             If Rs.Fields(0) = vCombo Then cmbadvocateid.ListIndex = i
  198.             i = i + 1
  199.         End If
  200.         Rs.MoveNext
  201.     Wend
  202.     Rs.Close
  203. End Function
  204. Public Sub Grid_Data()
  205. On Error GoTo ChkErr
  206.     Adodc1.ConnectionString = pStrConnectionString
  207.     Adodc1.RecordSource = "Select ID,Description,CourtId,CaseId as CaseNo,AdvId,Advname as AdvocateName,PersonAttend,Result,convert(varchar(20),Proceedings.Nextdt,6) as NextDate,convert(VarChar(20), Proceedings.Reminddt, 6) As RemindDate From Proceedings"
  208.     Adodc1.Refresh
  209.     Set MSHFlexGrid1.DataSource = Adodc1
  210.     Set MSHFlexGrid1.Recordset = Adodc1.Recordset
  211.     Adodc1.Refresh
  212.     MSHFlexGrid1.ColWidth(1) = 800
  213.     MSHFlexGrid1.ColWidth(2) = 3000
  214.     MSHFlexGrid1.ColWidth(3) = 1000
  215.     MSHFlexGrid1.ColWidth(4) = 800
  216.     MSHFlexGrid1.ColWidth(5) = 800
  217.     MSHFlexGrid1.ColWidth(6) = 2000
  218.     MSHFlexGrid1.ColWidth(7) = 2000
  219.     MSHFlexGrid1.ColWidth(8) = 1500
  220.     MSHFlexGrid1.ColWidth(9) = 1500
  221.     MSHFlexGrid1.ColWidth(10) = 1500
  222.     MSHFlexGrid1.Refresh
  223. Exit Sub
  224. ChkErr:
  225. If Err.Number > 0 Then
  226. MsgBox Err.Number & vbNewLine & Err.Description
  227.            Call ErrHand("frmProceedings", "Grid_Data")
  228.     'Resume Next
  229. End If
  230. End Sub
  231.  
  232. Private Sub FormUpdateSQL1_AddClick()
  233. DTPnextdt.Value = Date
  234. DTPReminddt.Value = Date
  235. cmbcaseId.Enabled = True
  236. cmbcourtid.Enabled = True
  237. cmbadvocateid.Enabled = True
  238. cmbResult.Enabled = True
  239. cmbResult.Enabled = True
  240. txtId.Text = GetNextCode("Proceedings", "ID")
  241. 'txtAdvocateId.Text = GetNextCode("Advocate", "AdvID")
  242. 'cmbResult.Enabled = True
  243. txtId.Enabled = False
  244. 'cmbResult.Enabled = True
  245. 'txtAdvocateId.Enabled = False
  246. 'ChkInd.Value = 1
  247. End Sub
  248.  
  249. Private Sub FormUpdateSQL1_AfterControlsEnabled()
  250. 'FormUpdateSQL1.DoVisible 5, False
  251. 'FormUpdateSQL1.DoVisible 1, False
  252. cmbcaseId.Enabled = True
  253. cmbResult.Enabled = True
  254. cmbcourtid.Enabled = True
  255. cmbadvocateid.Enabled = True
  256. End Sub
  257.  
  258. Private Sub FormUpdateSQL1_AfterUpdate()
  259. cmbResult.Enabled = True
  260. cmbcaseId.Enabled = True
  261. cmbcourtid.Enabled = True
  262. cmbadvocateid.Enabled = True
  263. Call Grid_Data
  264. End Sub
  265. Private Sub FormUpdateSQL1_BeforeValidate()
  266. If cmbResult.Text = "" Then
  267. MsgBox " Enter the particular result"
  268. cmbResult.SetFocus
  269. FormUpdateSQL1.CancelEvent = True
  270. End If
  271. Exit Sub
  272. FormUpdateSQL1.CancelEvent = True
  273. End Sub
  274.  
  275.  
  276. Private Sub MSHFlexGrid1_DblClick()
  277. FormUpdateSQL1.ViewRecord True, Val(MSHFlexGrid1.Text)
  278. End Sub
  279.  
  280.  
  281.  
Feb 6 '09 #3
squrel
143 100+
Is anyone can help me here? i have past the full code tht i m working on it
thank u
Feb 9 '09 #4
debasisdas
8,127 Expert 4TB
@squrel
thats why noone is looking at them.

when you post the code ,do not post all the code you have.

just post the part that you are facing problem with.---i hope that makes sence
Feb 9 '09 #5
squrel
143 100+
Hi..
i m very sorry bt u told me to send the code tht i m working on it.. thts why i send the whole code of tht form... ok my problem is this part... i have setfocus here bt my combo box content still getting repeted.. i have filled my combo box from the properties.. am i missing something? wil u plz look at this part and let me knw..
thanks a lot


Expand|Select|Wrap|Line Numbers
  1. Private Sub FormUpdateSQL1_BeforeValidate()
  2. If cmbResult.Text = "" Then
  3. MsgBox " Enter the particular result"
  4. cmbResult.SetFocus
  5. FormUpdateSQL1.CancelEvent = True
  6. End If
  7. Exit Sub
  8. FormUpdateSQL1.CancelEvent = True
  9.  End Sub
  10.  
Feb 10 '09 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Diane Yocom | last post by:
Has anybody ever seen or written code for ASP that would mimic Access' multi-column combo box? Specifically, I have a drop down box that lists about 100 five-digit codes. Each of these codes has...
5
by: Marnie Parker | last post by:
I am adding a drop down comb box to an existing database I wrote about a year ago. This combo box list names where the user can select which record to go to. Sigh. Last, First Name and a...
3
by: mal | last post by:
Sorry for repost - system added to another subject for some reason Have tried numerous ideas from the group to solve this one. It is such a simple example that it should be straightforward ! I...
5
by: Paul | last post by:
I have read the posts on using Sendkeys to dropdown the list in a combo box. However, doesn't that require the combo box to have the focus? My situation is a little different. I have a text...
10
by: lorirobn | last post by:
Hi, I have a form with several combo boxes, continuous form format, with record source a query off an Item Table. The fields are Category, Subcategory, and Color. I am displaying descriptions,...
2
by: Eric Layman | last post by:
Hi, I have a radio button and a combo box. Upon changing a value for radio button, the combo box values will be dynamically updated. I have an idea on how to go abt doing it but Im stuck...
30
ADezii
by: ADezii | last post by:
This week’s Tip of the Week will clearly demonstrate how you can dynamically set the Drop Down List Width of a Combo Box to the length of the longest item in its Row Source. The inspiration for this...
4
by: Karl | last post by:
Using A2000 with 2 tables Table 1 is a reference table with 2 fields Table 2 has 2 fields and 2 combo boxes to lookup date in table 1 Combo1 binds to col 1 in table 1, this works OK Combo 2...
1
by: bytenut | last post by:
I would like to display two field values in a combo after selecting from the list items... i.e. my drop-down shows two fields from a lookup, but when I select the item, only the first field value is...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.