Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

ado combo & text box dinding error?
Hi,
I have a problem with biding(I think) a combo box with text boxes.
The combo and text boxes on my form are loaded with the correct data.
But, when I click on the combo box and select a different data member
the combo box reflects the selected change(text changes) OK but my
text boxes do not. - the text is unchanged.
I have tried a number of variations of code with no luck.
In my code below if I change the customerID combo box value the first
and last names do not change
Any help as to how to fix this problem will be appreciated
regards
Eric

my form load:

call creatCon
Do Until rsCustomer.EOF
If Not IsNull(rsCustomer!CustomerID) Then
cboCustomerID.AddItem rsCustomer!CustomerID
rsCustomer.MoveNext
Loop
Set cboCustomerID.DataSource = rsCustomer
cboCustomerID.DataField = "CustomerID"
Set txtCustomerFirstName.DataSource = rsCustomer
txtCustomerFirstName.DataField = "CustomerFirstName"
Set txtCustomerLastName.DataSource = rsCustomer
txtCustomerLastName.DataField = "CustomerLastName"

If cboCustomerID.ListCount > 0 Then
rsCustomer.MoveFirst
cboCustomerID.Text = rsCustomer!CustomerID
End If

my Bas module:

Public cnCustomer As New ADODB.Connection
Public rsCustomer As New ADODB.Recordset
Public strConn As String

Public Function createCon()
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=G:\INCAT.mdb;Mode=ReadWrite;Persist Security Info=False"
Set cnCustomer = New ADODB.Connection
Set rsCustomer = New ADODB.Recordset

Debug.Print "Connection Object Created"
If cnCustomer.State = adStateClosed Then
cnCustomer.CursorLocation = adUseClient
cnCustomer.Open strConn
End If
rsCustomer.Open "SELECT * FROM tblCustomer ORDER BY CustomerID",
cnCustomer, adOpenStatic, adLockBatchOptimistic, adCmdText
Debug.Print "Recordset Customer Created"

Set rsCustomer.ActiveConnection = Nothing
cnCustomer.Close

End Function

Report this thread to moderator Post Follow-up to this message
Old Post
Eric
10-25-04 08:56 PM


Re: ado combo & text box dinding error?
What code do you have in cboCustomerID_Click() event?
If none, you should have some.....

--- Andy

>-----Original Message-----
>Hi,
>I have a problem with biding(I think) a combo box with
text boxes.
>The combo and text boxes on my form are loaded with the
correct data.
>But, when I click on the combo box and select a different
data member
>the combo box reflects the selected change(text changes)
OK but my
>text boxes do not. - the text is unchanged.
>I have tried a number of variations of code with no luck.
>In my code below if I change the customerID combo box
value the first
>and last names do not change
>Any help as to how to fix this problem will be appreciated
>regards
>Eric
>
>my form load:
>
>       call creatCon
>       Do Until rsCustomer.EOF
>        If Not IsNull(rsCustomer!CustomerID) Then
>cboCustomerID.AddItem rsCustomer!CustomerID
>        rsCustomer.MoveNext
>    Loop
>           Set cboCustomerID.DataSource = rsCustomer
>    cboCustomerID.DataField = "CustomerID"
>           Set txtCustomerFirstName.DataSource =
rsCustomer
>    txtCustomerFirstName.DataField = "CustomerFirstName"
>           Set txtCustomerLastName.DataSource = rsCustomer
>   txtCustomerLastName.DataField = "CustomerLastName"
>
>        If cboCustomerID.ListCount > 0 Then
>        rsCustomer.MoveFirst
>        cboCustomerID.Text = rsCustomer!CustomerID
>    End If
>
>my Bas module:
>
>Public cnCustomer As New ADODB.Connection
>Public rsCustomer As New ADODB.Recordset
>Public strConn As String
>
>Public Function createCon()
>strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
>Source=G:\INCAT.mdb;Mode=ReadWrite;Persist Security
Info=False"
>       Set cnCustomer = New ADODB.Connection
>       Set rsCustomer = New ADODB.Recordset
>
>    Debug.Print "Connection Object Created"
>    If cnCustomer.State = adStateClosed Then
>        cnCustomer.CursorLocation = adUseClient
>        cnCustomer.Open strConn
>    End If
>    rsCustomer.Open "SELECT * FROM tblCustomer ORDER BY
CustomerID",
>cnCustomer, adOpenStatic, adLockBatchOptimistic, adCmdText
>    Debug.Print "Recordset Customer Created"
>
>    Set rsCustomer.ActiveConnection = Nothing
>    cnCustomer.Close
>
>End Function
>.
>

Report this thread to moderator Post Follow-up to this message
Old Post
Andy
10-25-04 08:56 PM


Re: ado combo & text box dinding error?
"Andy" <Andrzej7@hotmail.com> wrote in message news:<150a01c4babd$d53ce6a0$a301280a@phx.gbl
>...
> What code do you have in cboCustomerID_Click() event?
> If none, you should have some.....
>
> --- Andy
> 
>  text boxes. 
>  correct data. 
>  data member 
>  OK but my 
>  value the first 
>  rsCustomer 
>  Info=False" 
>  CustomerID", 

Thanks for reply.
But add what?
tried variations of populating boxes with recorset - messy
also tried moving the record in the boxes to the selected one which I
assume is what your supposed to do, again this does'nt work either
any further help appreciated
regards
Eric

Report this thread to moderator Post Follow-up to this message
Old Post
Eric
10-26-04 08:55 AM


Re: ado combo & text box dinding error?
Eric,
When you click on the combo box, you need to move to the related record in
order to make that record the current record. So in the Click event of the
Combo, do something like:
rsCustomer.MoveFirst
Do While not rsCustomer.EOF
If rsCustomer!CustomerID = cboCustomer.List(cboCustomer.ListIndex) Then
'Found the matching record
Exit Do
End If
rsCustomer.MoveNext
Loop

You can also use the Filter method or Find as you prefer.

You may want to add code to check the status of the current record to see if
it has been changed before moving off the current recordset and performing
the appropriate Update or Cancel methods on it.

HTH,
CF
"Eric" <estacey@chariot.net.au> wrote in message
news:d16bbdbf.0410250928.23acd472@posting.google.com...
> Hi,
> I have a problem with biding(I think) a combo box with text boxes.
> The combo and text boxes on my form are loaded with the correct data.
> But, when I click on the combo box and select a different data member
> the combo box reflects the selected change(text changes) OK but my
> text boxes do not. - the text is unchanged.
> I have tried a number of variations of code with no luck.
> In my code below if I change the customerID combo box value the first
> and last names do not change
> Any help as to how to fix this problem will be appreciated
> regards
> Eric
>
> my form load:
>
>       call creatCon
>       Do Until rsCustomer.EOF
>        If Not IsNull(rsCustomer!CustomerID) Then
> cboCustomerID.AddItem rsCustomer!CustomerID
>        rsCustomer.MoveNext
>    Loop
>           Set cboCustomerID.DataSource = rsCustomer
>    cboCustomerID.DataField = "CustomerID"
>           Set txtCustomerFirstName.DataSource = rsCustomer
>    txtCustomerFirstName.DataField = "CustomerFirstName"
>           Set txtCustomerLastName.DataSource = rsCustomer
>   txtCustomerLastName.DataField = "CustomerLastName"
>
>        If cboCustomerID.ListCount > 0 Then
>        rsCustomer.MoveFirst
>        cboCustomerID.Text = rsCustomer!CustomerID
>    End If
>
> my Bas module:
>
> Public cnCustomer As New ADODB.Connection
> Public rsCustomer As New ADODB.Recordset
> Public strConn As String
>
> Public Function createCon()
> strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data
> Source=G:\INCAT.mdb;Mode=ReadWrite;Persist Security Info=False"
>       Set cnCustomer = New ADODB.Connection
>       Set rsCustomer = New ADODB.Recordset
>
>    Debug.Print "Connection Object Created"
>    If cnCustomer.State = adStateClosed Then
>        cnCustomer.CursorLocation = adUseClient
>        cnCustomer.Open strConn
>    End If
>    rsCustomer.Open "SELECT * FROM tblCustomer ORDER BY CustomerID",
> cnCustomer, adOpenStatic, adLockBatchOptimistic, adCmdText
>    Debug.Print "Recordset Customer Created"
>
>    Set rsCustomer.ActiveConnection = Nothing
>    cnCustomer.Close
>
> End Function



Report this thread to moderator Post Follow-up to this message
Old Post
Wart
10-28-04 01:55 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:02 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.