⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmdeserts.frm

📁 菜谱管理系统。比较简单的VB代码
💻 FRM
📖 第 1 页 / 共 2 页
字号:
        cmdSave.Enabled = True
        cmdDelete.Enabled = False
        CmdEdit.Enabled = False
        cmdAdd.Enabled = False
        cmdList.Enabled = False
        Data1.Recordset.AddNew
        Data1.Refresh
'Keeps the user updated on the programs status

            fMainForm.sbStatusBar.Panels(1).Text = "Status: Adding Record To Database..."
            fMainForm.sbStatusBar.Refresh

End Sub

Private Sub cmdDelete_Click()

' Deletes a record for the cook.mdb

    Data1.Recordset.Delete
    Data1.Refresh
    
'Keeps the user updated on the programs status

    fMainForm.sbStatusBar.Panels(1).Text = "Status: Deleting Record From Database..."
    fMainForm.sbStatusBar.Refresh
    Timer1.Enabled = True

End Sub

Private Sub cmdEdit_Click()

' sets the textbox enabled property yo true
' so the cooc.mdb can be edited

    txtName.Enabled = True
    txtSource.Enabled = True
    txtNotes.Enabled = True
    txtIngredients.Enabled = True
    txtDirections.Enabled = True

' allows the user to edit the current record in the cook.mdb
' also disables the Add, Delete, cmdList buttons
' and sets the visible property to false for the edit button
' and sets the cisible property for the Done Edit button to ture

        cmdSave.Enabled = False
        cmdDelete.Enabled = False
        CmdEdit.Visible = False
        cmdEditDone.Visible = True
        cmdAdd.Enabled = False
        cmdList.Enabled = False
        Data1.Recordset.Edit

'Keeps the user updated on the programs status

            fMainForm.sbStatusBar.Panels(1).Text = "Status: Editing Current Record..."
            fMainForm.sbStatusBar.Refresh

End Sub

Private Sub cmdEditDone_Click()

' Sets the text boxes propertys to false
' to keep the cook.mdb from being changed

    txtName.Enabled = False
    txtSource.Enabled = False
    txtNotes.Enabled = False
    txtIngredients.Enabled = False
    txtDirections.Enabled = False

' closes the edit mode for the cook.mdb
' also enables the Delete, Add, cmdList buttons
' and sets the visible property for Edit done to false
' and sets the visible property for the edit button to true

        cmdSave.Enabled = False
        cmdDelete.Enabled = True
        CmdEdit.Visible = True
        cmdEditDone.Visible = False
        cmdAdd.Enabled = True
        cmdList.Enabled = True
        Data1.Recordset.Edit
        Data1.Refresh

'Keeps the user updated on the programs status

            fMainForm.sbStatusBar.Panels(1).Text = "Status: Saving Changes To Database..."
            fMainForm.sbStatusBar.Refresh
            Timer1.Enabled = True

End Sub

Private Sub cmdList_Click()

' Opens the dbList (quick Recipe find)
' Also refreshes the list so that its current

    dbList.Refresh
    dbList.Visible = True

End Sub

Private Sub cmdSave_Click()

' Sets the textbox propertys to false
' To keep the cook.mdb from being changed

    txtName.Enabled = False
    txtSource.Enabled = False
    txtNotes.Enabled = False
    txtIngredients.Enabled = False
    txtDirections.Enabled = False

' Saves a new record in the cook.mdb
' Also enables the Delete, Edit, Add, cmdList buttons
' And disables the save button

        cmdSave.Enabled = False
        cmdDelete.Enabled = True
        CmdEdit.Enabled = True
        cmdAdd.Enabled = True
        cmdList.Enabled = True
        Data1.Recordset.AddNew
        Data1.Refresh
        
'Keeps the user updated on the programs status

            fMainForm.sbStatusBar.Panels(1).Text = "Status: Saving Record To Database..."
            fMainForm.sbStatusBar.Refresh
            Timer1.Enabled = True

End Sub
Private Sub Data1_Error(DataErr As Integer, Response As Integer)
  
  'This is where you would put error handling code
  'If you want to ignore errors, comment out the next line
  'If you want to trap them, add code here to handle them
  
    MsgBox "Data error event hit err:" & Error$(DataErr)
    Response = 0  'throw away the error

End Sub

Private Sub Data1_Reposition()
  
     Screen.MousePointer = vbDefault
  On Error Resume Next
  
  'This will display the current record position
  'for dynasets and snapshots
  
        Data1.Caption = "Recipe Record: " & (Data1.Recordset.AbsolutePosition + 1)
  
  'for the table object you must set the index property when
  'the recordset gets created and use the following line
  
  'Data1.Caption = "Record: " & (Data1.Recordset.RecordCount * (Data1.Recordset.PercentPosition * 0.01)) + 1

End Sub

Private Sub dbList_Click()

' This code updates the rest of the forms data
' fields when a record is selected
' From DBCNames

    Dim rs As Object
    Set rs = Me.Data1.Recordset.Clone
' NOTE:  [Name] = Record Field [dbList] = componet name
        rs.FindFirst "[Name] = '" & Me![dbList] & "'"
        Me.Data1.Recordset.Bookmark = rs.Bookmark
' NOTE: dbList = componet name
            dbList.Visible = False

End Sub

Private Sub FileClose_Click()

' Closes the current form (frmDeserts)

    Unload Me

End Sub

Private Sub FileExit_Click()

' Terminates the program and returns to the operating system

    End

End Sub



Private Sub Form_Load()

' Starts the timer for the status bar

    Timer1.Enabled = True

End Sub



Private Sub Form_Click()

' makes sure the dbList is hidden

    dbList.Visible = False

End Sub

Private Sub Form_Unload(Cancel As Integer)

' Updates the status bar for the user

    fMainForm.sbStatusBar.Panels(1).Text = "Status: Closing Database..."
    fMainForm.sbStatusBar.Refresh
    fMainForm.Timer1.Enabled = True

End Sub

Private Sub Frame1_Click()

' makes sure the dbList is hidden

    dbList.Visible = False

End Sub

Private Sub Frame2_Click()

' makes sure the dbList is hidden

    dbList.Visible = False

End Sub

Private Sub Label2_Click()

' makes sure the dbList is hidden

    dbList.Visible = False

End Sub

Private Sub Print_Click()

'Keeps the user updated on the programs status

    fMainForm.sbStatusBar.Panels(1).Text = "Status: Loading Print Form..."
    fMainForm.sbStatusBar.Refresh

' Opens the printing form wich starts printing data

        FrmDPrint.Show

End Sub

Private Sub RecipesMeals_Click()

'Keeps the user updated on the programs status

    fMainForm.sbStatusBar.Panels(1).Text = "Status: Opening Database..."
    fMainForm.sbStatusBar.Refresh

' Shows the frmDeserts for the user

        frmDeserts.Show
' Shows the frmMeals for the user

            frmMeals.Show

End Sub

Private Sub tile_Click()

'tiles te windows in the main form

    fMainForm.Arrange vbTileVertical

End Sub

Private Sub Timer1_Timer()

'Keeps the user updated on the programs status

    fMainForm.sbStatusBar.Panels(1).Text = "Status: Running..."
    fMainForm.sbStatusBar.Refresh
    Timer1.Enabled = False
    Data1.Refresh
    
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -