Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

OK what am I doing wrong here ?

[b][red]This message was edited by Lensmeister at 2005-7-25 9:29:16[/red][/b][hr]
Hi everyone ... can someone please hep me .... when I clickl the toolbar to add a record the focus is on the correct bos I enter the details and then click the save button on the toolbar. BUT nothing saves ......
[code]
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Index
Case 1
On Error Resume Next
adoJournal.Recordset.AddNew
'txtDayNum.SetFocus
Case 2
If Not adoJournal.Recordset.BOF Then
adoJournal.Recordset.MoveFirst
If adoJournal.Recordset.BOF Then
MsgBox "You are at the First Entry already"
End If
End If
lblDatabaseInfo.Caption = "Journal Number " & (adoJournal.Recordset.AbsolutePosition) & " of " & adoJournal.Recordset.RecordCount & " !"
Case 3
' Move BACK one Record in the database.
If Not adoJournal.Recordset.BOF Then
adoJournal.Recordset.MovePrevious
If adoJournal.Recordset.BOF Then
MsgBox "You are at the begining of the Journal Databse"
adoJournal.Recordset.MoveNext
End If
End If
lblDatabaseInfo.Caption = "Journal Number " & (adoJournal.Recordset.AbsolutePosition) & " of " & adoJournal.Recordset.RecordCount & " !"

Case 4
' Move forward one Record in the database.
If Not adoJournal.Recordset.EOF Then
adoJournal.Recordset.MoveNext
If adoJournal.Recordset.EOF Then
MsgBox "You are at the end of the Journal Databse"
adoJournal.Recordset.MovePrevious
End If
End If
lblDatabaseInfo.Caption = "Journal Number " & (adoJournal.Recordset.AbsolutePosition) & " of " & adoJournal.Recordset.RecordCount & " !"
Case 5
If Not adoJournal.Recordset.EOF Then
adoJournal.Recordset.MoveLast
If adoJournal.Recordset.EOF Then
MsgBox "You are at the Last Entry already"
End If
End If
lblDatabaseInfo.Caption = "Journal Number " & (adoJournal.Recordset.AbsolutePosition) & " of " & adoJournal.Recordset.RecordCount & " !"
Case 6
' Save the entries
On Error Resume Next
adoJournal.Recordset.Update ("number, day, year, title, daysummary, summary, dateoutward, datereturn, country, destination")
adoJournal.Refresh
MsgBox ("Update to journal databse is completed successfully")

Case 7
'database refresh
adoJournal.Refresh
End Select
End Sub
[/code]
the onload is thus:
[code]
Private Sub Form_Load()
On Error GoTo 100
'Connecting to the DB for Access 2000 or higher DB name
adoJournal.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & " ravelogue.mdb" & ";Jet OLEDB:Database Password="
' SQL Statement to Select * (all Fields) from the Table Named journal)
adoJournal.RecordSource = "Select * FROM journal ORDER BY journal.Number, journal.day"
adoJournal.Refresh
lblDatabaseInfo.Caption = "Journal Number " & (adoJournal.Recordset.AbsolutePosition) & " of " & adoJournal.Recordset.RecordCount & " !"

Exit Sub
100
MsgBox Err.Description
End Sub
[/code]

Thanks for any help,




Comments

  • PrzemekG_PrzemekG_ Posts: 595Member
    First of all, use On Local Error ...., because once VB see "On Error" it use the action for the rest of the program (or at least for any subcalls). This made me some problems long time ago :)


    [code]
    Case 2
    If Not adoJournal.Recordset.BOF Then
    adoJournal.Recordset.MoveFirst
    If adoJournal.Recordset.BOF Then
    MsgBox "You are at the First Entry already"
    End If
    End If
    [/code]

    I think this condition, when the MsgBox is displayed means "There are no records" :), BOF means BEFORE the first record, after you MoveFirst, you should be at the first one, not before it :)

    I don't realy know how you set values to text boxes, but I think you should use Fields collection. Then when you use Update (without arguments) it should update the values without any problem.

Sign In or Register to comment.