Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 2002
    Posts
    59

    Unanswered: Text Box Field Does Not Appear

    Hi everyone

    I am updating 9 fields in my form's Text Boxes by using code below -which is not the problem I believe -:

    ================================================== =======

    Dim cn As ADODB.Connection
    Dim rs As ADODB.Recordset

    Set cn = CurrentProject.AccessConnection

    Set rs = New ADODB.Recordset
    With rs
    Set .ActiveConnection = cn
    .Source = "SELECT SwimmersID,Group, Email, LastName, Address, Suburb, PostCode, MothersName, FathersName, HomePhone, MobilePhone, WorkPhone, FirstName " _
    & "FROM [Swimmers Table] " _
    & "WHERE (((Email IS NOT NULL) AND(Group <> 0) AND(Group)=" & [Forms]![SwimmersForm]![Group] & "));"
    .Open
    End With

    If rs.RecordCount > 0 Then
    Me.Email.Value = rs.Fields(2)
    Me.LastName.Value = rs.Fields(3)
    Me.Address.Value = rs.Fields(4)
    Me.Suburb.Value = rs.Fields(5)
    Me.PostCode.Value = rs.Fields(6)
    Me.MothersName.Value = rs.Fields(7)
    Me.FathersName.Value = rs.Fields(8)
    Me.HomePhone.Value = rs.Fields(9)
    Me.MobilePhone.Value = rs.Fields(10)
    Me.WorkPhone.Value = rs.Fields(11)
    Me.FirstName.Value = rs.Fields(12)
    End If

    Set rs = Nothing
    Set cn = Nothing
    ================================================== =======

    So After update I can see some of the fields (i.e. Address, Suburb, FathersName, HomePhone, MobilePhone) but I cannot see some others (i.e. MothersName, WorkPhone)

    When I check database it's there. And also I am clicking on the field, or going back to another record and come back then it appears.

    But if I just try to wait and see I cannot see it no matter how long I wait.

    Thanks everyone!!!!!
    Cuneyt
    Last edited by cuneyt; 04-05-07 at 04:44.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    What ever happened to good old fashioned debugging?
    Stick break points on each line within your If statement and watch the values populate as you step through.

    Also, do you want .Value or .Text ? Might be worth a play.
    George
    Home | Blog

  3. #3
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    got to agree with george, a bit of DEBUGGING should be the first weapon of choice

    mebbe some debug.prints, mebbe some msgbox

    id use eof & bof to see if there were records thererecords there.. im not even certain that recordcount is populated on a query. but Id want to check that in the help system.

    first thing Id do is check that the SQL is retrieving what you expect (ie the columns and values that you expect)

    so id put a msgbox immediately after the SQL has been invoked, that way round Id know that its my assignment statement that is dependable.

    Id agree with the comment assigning values, id also use
    lastname.text = rs!LastName in place of Me.LastName.Value = rs.Fields(3)

    ..mind you Id also use the with construct to improve readability and marginally improve performance
    with rs
    if .recordcount > 0
    lastname.text = !LastName
    .......other statementds as required
    endif
    end with

    im not even sure you need to specify the .text or .value as unlike .net there is no need to explicitly specify the control as it default action is to populate the text box.
    I'd rather be riding on the Tiger 800 or the Norton

  4. #4
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    In VBA the default is .Value so that lastname is the same as lastname.Value. lastname.text, however, can only be used when the lastname control actually has focus.
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •