DD's Stats

Members
Total Members: 157
Latest: irsmalik
New This Month: 7
New This Week: 3
New Today: 0
Stats
Total Posts: 876
Total Topics: 444
Most Online Today: 3
Most Online Ever: 52
(May 02, 2020, 05:24:19 pm)
Users Online
Members: 0
Guests: 1
Total: 1

Recommended Posts

DD Approved Members group Added by DD Admin
05-06-2020, 12:48:35


Posting Additions or alterations rules by DD Admin
27-02-2020, 10:33:01


A Trip Down Memory Lane by DD Admin
24-08-2019, 14:17:16


Todays Birthdays

DD's Top Posters

DD Admin
Posts: 910
borobutch
Posts: 69
Carol
Posts: 12
Ram
Posts: 8
Clarissa
Posts: 8
richardsoj
Posts: 5
ComputerTech
Posts: 5

Author Topic: Fill list and open any form  (Read 15 times)

0 Members and 0 Guests are viewing this topic.

Offline DD Admin

  • Administrator
  • Hero Member
  • *****
  • Posts: 910
  • Karma: +5/-0
  • Gender: Male
  • Db Dreams Owner
  • Location: Margate, UK
  • Referrals: 16
Fill list and open any form
« on: July 08, 2020, 11:47:13 am »
This function will add a new record to the table you indecate and open the form you indecate

Code: [Select]
'=======Add Under Option Explicit===================================================================
Private m_rst As Recordset
'Used for all my List filling functions which have worked without fault for 18 years
Private m_IntNew As Integer 'used to test the response from message box
Private Const m_strMsg As String = " Is Not An Item In The List Would You Like To Add It"
'Part Of all list filling funtions message
Private Const m_strUndoMsg As String = " Is Not In the List Undoing Entry"
 'Part of the list filling function undo message
Private Const m_strTitle As String = "Undoing Invalid Entry" 'Undo title
'==========================================================================================
 
Public Function FillListsOneExt(StrItem As String, StrTable As String, _
                            StrField As String, StrForm As String, IDField As String) As Integer
'=================================================================
'Description: Add Any Item Then open Any form to Display the new record for editing
'Called By: Combo Box After Update
'Calling:
'    Response = FillListsOneExt(NewData, "Table", "Field", "Form", "ID")
'        If Response = acDataErrContinue Then
'            DoCmd.RunCommand acCmdUndo
'        End If
'Parameters:
'StrItem = Field Name Form new Date
'StrTable = Table Name To Update
'StrForm = Name Of Form To Open
'IDField = ID Field to Limit form data
'Returns:  acDataErrAdded or acDataErrContinue
'Author: Michael Javes
'Editor(s) : None
'Date Created: 2006-2008
'Rev. History: None
'Requirements:
'=================================================================
Dim NewID As Long
On Error GoTo Err_HandleErr
    m_IntNew = MsgBox(StrItem & m_strMsg, vbInformation + vbYesNo, "Item Not In List")
    If m_IntNew = vbYes Then
        Set m_rst = CurrentDb.OpenRecordset(StrTable)
        m_rst.AddNew
        m_rst(StrField) = StrItem
        NewID = m_rst(IDField)
        m_rst.Update
        FillListsOneExt = acDataErrAdded
        m_rst.Close
        Set m_rst = Nothing
        DoCmd.OpenForm StrForm, , , "[" & IDField & "]=" & NewID, , acDialog, "Adding"
    Else
        MsgBox StrItem & m_strUndoMsg, , m_strTitle
            FillListsOneExt = acDataErrContinue
    End If
   
Exit_HandleErr:
    Exit Function
   
Err_HandleErr:
    Select Case Err.Number
        Case Else
            MsgBox "Error: " & Err.Description & " (" & Err.Number & ")"
            Resume Exit_HandleErr
        Resume
    End Select
End Function
« Last Edit: July 08, 2020, 12:15:29 pm by DD Admin »

Share on Facebook Share on Twitter


 

Related Topics

  Subject / Started by Replies Last post
0 Replies
45 Views
Last post August 20, 2019, 11:47:13 am
by DD Admin
0 Replies
43 Views
Last post September 20, 2019, 07:27:42 pm
by DD Admin
0 Replies
107 Views
Last post November 17, 2019, 01:01:55 am
by DD Admin
0 Replies
40 Views
Last post February 21, 2020, 09:13:44 pm
by DD Admin
0 Replies
20 Views
Last post April 14, 2020, 01:44:37 pm
by DD Admin

DD's Social Media

DD's Programs


Development Schedule

DD's Freeware

Apollo

DJ 2020

Chart Tracker Elite

Works Manager

Contact Manager

Simple Home Accounts

Book Library

Picture Library

Project Manager (accde)


Developer Tools

Project Manager (accdb)

Style Manager

Code Library


Open Code Templates

Master Template

Task Management

Charitable Contributions

Bug Tracker Template

Time And Billing Template

Real Estate Template

Household Inventory V1


Open Code Examples

DD's Northwind V1

Employee Example V5

Grid Demo Example V1

Employee Example V4

Small Examples


Recent Topics

Apollo Project Status by DD Admin
January 15, 2021, 11:00:15 am

Apollo Manual: Main Music Player by DD Admin
January 13, 2021, 10:21:36 am

UK Singles/Albums Charts 01 Jan 2021 to 07 Jan 2021 Analysis by borobutch
January 11, 2021, 09:27:29 pm

Please welcome irsmalik to DD by DD Admin
January 11, 2021, 09:34:58 am

Please welcome FamiliaRoca to DD by DD Admin
January 11, 2021, 07:49:40 am

Please welcome Gasman to DD by DD Admin
January 10, 2021, 02:01:23 pm

Please welcome ferrancc to DD by DD Admin
January 09, 2021, 06:21:49 pm

Database Dreams is not affiliated with Microsoft