Results 1 to 3 of 3

Thread: Added records not displaying

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2003
    Posts
    67

    Added records not displaying

    I have a problem with my recordset (coming from an access table through an ado connection object)
    I can add a record from vb to access and it is added correctly to the access table, but ..HERE COMES THE PROBLEM... I cant view the record in Vb when i try to scroll through it, it is only the former recordset that is displayed.

    (Sorry about the messiness of the code)
    VB Code:
    1. Private Sub cmdAdd_Click()
    2.  
    3.  
    4. 'Allows the user to add a new record
    5. 'to the list of clients.
    6. 'Hides the various text/Combo boxes.
    7.     txtFName.Locked = False
    8.     txtLName.Locked = False
    9.     txtStreet.Locked = False
    10.     txtTown.Locked = False
    11.     cboCounty.Locked = False
    12.     txtPhoneNo.Locked = False
    13.     txtPreferences.Locked = False
    14.     cboAge.Locked = False
    15.     cmdHistory.Visible = False
    16.     cmdAddSave.Visible = True
    17.     fraControls.Visible = False
    18.     cmdBack.Visible = True
    19.    
    20.      rsDetails.AddNew
    21.  
    22. 'rsDetails.Requery
    23.  
    24.  
    25. End Sub
    26.  
    27.  
    28. Private Sub cmdAddSave_Click()
    29. If txtFName.Text = "" Or txtLName.Text = "" Or txtStreet.Text = "" Or txtTown.Text = "" Or cboCounty.Text = "" Or txtPhoneNo.Text = "" Or cboAge.Text = "" Then
    30. MsgBox "Please Complete the Missing Details", vbCritical, "Missing Details"
    31. Else
    32. rsDetails.Update
    33.  
    34.  
    35. rsDetails.Requery
    36.      MsgBox "Record Added Successfully", vbInformation, "Client Record Added"
    37.  
    38. End If
    39. End Sub
    40.  
    41.  
    42.  
    43. Private Sub Form_Load()
    44.  
    45.        
    46.         Set cnDetails = New Connection
    47.         Set comDetails = New Command
    48.         Set rsDetails = New Recordset
    49.         Dim strDetails As String
    50.         Dim rsStaff As Recordset
    51.         Dim comStaff As Command
    52.         Dim strStaff As String
    53.        
    54.     'Determines the provider and the connection to
    55.     'the specified database.
    56.     cnDetails.Provider = "Microsoft.Jet.OLEDB.4.0"
    57.     cnDetails.ConnectionString = "A:\VBPRO_Compacted.mdb"
    58.  
    59.     'Opens the connection
    60.     cnDetails.Open
    61.  
    62.     'comDetails.ActiveConnection = cnDetails
    63.  
    64.     'SQL statement
    65.     strDetails = "SELECT tblClient.C_Number, tblClient.C_F_Name, tblClient.C_L_Name, tblClient.C_Street, tblClient.C_Town, tblClient.C_County,tblClient.C_Phone, tblClient.C_Age, tblClient.C_Preferences, tblClient.Notes FROM tblClient INNER JOIN History ON tblClient.C_Number = History.C_Number Order By tblClient.C_Number Asc "
    66.  
    67.    ' "SELECT tblClient.C_Number, tblClient.C_F_Name, tblClient.C_L_Name, tblClient.C_Street, tblClient.C_Town, tblClient.C_County, tblClient.C_Phone, tblClient.C_Age, tblClient.C_Preferences, tblClient.Notes, tblStaff.S_F_Name FROM tblStaff INNER JOIN tblClient ON (tblStaff.S_Number = tblClient.C_Prefered_Stylist)Order By tblClient.C_Number Asc "
    68.  
    69. '   ' .ActiveConnection = cnDetails
    70.    ' .CommandText = strDetails
    71. 'End With
    72.  
    73. 'Set rsDetails = comDetails.Execute
    74.  
    75.  
    76.     'rsDetails.Open strDetails, cnDetails, adOpenDynamic, adLockOptimistic
    77.  
    78.  
    79.  With rsDetails
    80.      .ActiveConnection = cnDetails
    81.      .CursorLocation = adUseClient
    82.      .CursorType = adOpenDynamic
    83.      .LockType = adLockOptimistic
    84.      .Open strDetails, cnDetails, adOpenDynamic, adLockOptimistic
    85.      
    86.   End With
    87.    
    88.    
    89.    
    90.    strStaff = "SELECT tblStaff.S_F_Name FROM tblStaff"
    91.    
    92.     With rsStaff
    93. '     .ActiveConnection = cnDetails
    94. '     .CursorLocation = adUseClient
    95.     ' .CursorType = adOpenDynamic
    96.      '.LockType = adLockOptimistic
    97.      '.Open strStaff, cnDetails, adOpenDynamic, adLockOptimistic
    98.      
    99.   End With
    100. '   Do While Not rsStaff.EOF
    101.    ' cboStylist.AddItem rsStaff.Fields("S_F_Name")
    102.     'rsStaff.MoveNext
    103.    ' Loop
    104.     'Calls the BindData funtion
    105.     BindData
    106.  
    107.  
    108. End Sub

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jan 2003
    Posts
    67
    Any takers? Someone help me???

  3. #3
    Junior Member
    Join Date
    Feb 2003
    Location
    Philadelphia
    Posts
    28
    I see where you're saving the data, but where are you trying to view it? Do you have code you can paste for that? Also, did you refresh the data before viewing it again after adding the record(s)?
    "Never let the facts get in the way of a good story, Harry!".....Richie Ashburn

Posting Permissions

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



Click Here to Expand Forum to Full Width