I can write to but not read the database

Discussion in 'Software' started by chris6690, Jul 7, 2009.

  1. chris6690

    chris6690 Private E-2

    I have writen code to write to the user specifided database that works:

    Code:
    Private Sub cmd_Cancel_Click() 
    ' Exits back to the main Page 
    Unload Me 
    End Sub 
    
    Private Sub cmd_OK_Click() 
    ' adds a new record to the database 
    dba_Log.Recordset.AddNew 
    ' Takes the Information that was entered and writes it into the new record 
    txt_Time2.Text = txt_Time.Text 
    txt_Date2.Text = txt_Date.Text 
    txt_BS2.Text = txt_BS.Text 
    txt_Carbs2.Text = txt_Carbs.Text 
    txt_AmountInsulin12.Text = txt_InsulinAmount1.Text 
    txt_InsulinAmount22.Text = txt_InsulinAmount2.Text 
    txt_InsulinType.Text = dbc_InsulinType1.Text 
    txt_InsulinType2.Text = dbc_InsulinType2.Text 
    txt_Notes2.Text = txt_Notes.Text 
    txt_PWR.Text = FirstName & " " & LastName 
    ' tells the user the record has been entered 
    MsgBox ("Record has been written, " & FirstName & " " & LastName) 
    
    Unload Me 
    
    End Sub 
    
    Private Sub Form_Load() 
    ' Disables the Main Page 
    frm_MainPage.Enabled = False 
    
    
    ' Sets the database to use 
    dba_Info.DatabaseName = filelocation3 
    dba_Log.DatabaseName = filelocation3 
    dba_insulin.DatabaseName = filelocation3 
    End Sub 
    
    Private Sub Form_Unload(Cancel As Integer) 
    ' enables the main page 
    frm_MainPage.Enabled = True 
    
    
    End Sub  
    Then I wrote code to read from the same file but it will only read from the original blank database.

    Code:
     Option Explicit 
    
    Private Sub cmd_AddRecord_Click() 
    ' Checks to see if a file is open 
    If filelocation3 = "" Then 
    MsgBox ("You have not opened a file, Please Open or Create a file for editing") 
    Exit Sub 
    
    Else 
    End If 
    ' loads the form addrecord 
    Load frm_AddRecord 
    frm_MainPage.Enabled = False 
    frm_AddRecord.Show 
    
    End Sub 
    
    Private Sub cmd_ViewAll_Click() 
    ' if a file has not been opened this will tell the user to open or create one 
    If filelocation3 = "" Then 
    MsgBox ("You have not opened or created a file to use. Please do so before trying to preform an operation") 
    Exit Sub 
    
    Else 
    End If 
    
    
    ' Turns the text Box on 
    txt_All.Visible = True 
    ' Turns all other visuals off 
    
    
    ' Shows all records 
    txt_All.Text = txt_Fname.Text & " " & txt_MiddleInitial.Text & " " & txt_LName.Text & vbCrLf & vbCrLf 
    
    dba_Log.Recordset.MoveFirst 
    
    Do Until txt_Date.Text = "" 
    txt_All.Text = txt_All.Text & "Date: " & txt_Date.Text & " Time: " & txt_Time.Text & " Blood Sugar: " _ 
    & txt_BS.Text & " Carbs: " & txt_Carbs.Text & " Insulin 1: " & txt_InsulinAmount1.Text & " " & _ 
    txt_InsulinType1.Text & " Insulin 2: " & txt_InsulinAmount2.Text & " " & txt_InsulinType2.Text _ 
    & vbCrLf & "Notes: " & txt_Notes.Text & vbCrLf & "Writen by: " & txt_PWR.Text & vbCrLf & vbCrLf 
    dba_Log.Recordset.MoveNext 
    Loop 
    
    End Sub 
    
    Private Sub Form_Activate() 
    ' Sets the Database to use 
    dba_Log.DatabaseName = filelocation3 
    dba_Info.DatabaseName = filelocation3 
    
    End Sub 
    
    Private Sub Form_Load() 
    
    
    ' Turns off add New user if you aren't an autorized user 
    If UserType <> "Owner" And UserType <> "Programer" And UserType <> "Admin" Then 
    mnu_NewUser.Enabled = False 
    Else 
    End If 
    
    
    End Sub 
    
    
    
    Private Sub mnu_Exit_Click() 
    ' ask if the user realy wants to exit 
    
    Dim q 
    
    q = MsgBox("Do You Realy Want to Quit?", 1, "") 
    If q = 1 Then 
    End 
    
    Else 
    End If 
    
    
    End Sub 
    
    Private Sub mnu_New_Click() 
    ' loads the form new 
    Load frm_New 
    frm_New.Show 
    End Sub 
    
    Private Sub mnu_NewUser_Click() 
    ' loads a form to add a new user 
    Load frm_NewUser 
    frm_MainPage.Enabled = False 
    frm_NewUser.Show 
    
    End Sub 
    
    Private Sub mnu_Open_Click() 
    ' loads the form open 
    Load frm_Open 
    frm_Open.Show 
    End Sub  
    If anyone has the time to read and analize the code I would very much apritiate it. Ans Thank you for all the help I have reseived and will receive..
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds