Kamis, 04 Mei 2017

[MS_AccessPros] Update another field from NotInList event

 

Hi John,


I have a Form "frmAddressSubform".


It has one Control "cboResidenceCity" , on its NotInList event following is the code:


    'On Error GoTo cboResidenceCity_NotInList_Err

    Dim intAnswer As Integer

    Dim strSQL As String

    intAnswer = MsgBox("City Name '" & Chr(34) & NewData & _

        Chr(34) & "' is not currently listed." & vbCrLf & _

        "Would you like to add it to the list now?" _

        , vbQuestion + vbYesNo + vbDefaultButton2, "SAC Pakistan - Guide")

    If intAnswer = vbYes Then

         strSQL = "INSERT INTO MainCity ([MainCityName])" & _

                 "VALUES ('" & NewData & "');"

        DoCmd.SetWarnings False

        DoCmd.RunSQL strSQL

        DoCmd.SetWarnings True

        MsgBox "The new 'City Name' " & Chr(34) & NewData & Chr(34) & " has been added to the list." _

            , vbInformation, "SAC Pakistan - Guide"

        Response = acDataErrAdded

    Else

        MsgBox "Please choose a 'City Name' from the list." _

            , vbInformation, "SAC Pakistan - Guide"

        Response = acDataErrContinue

    End If

cboResidenceCity_NotInList_Exit:

    Exit Sub

'------------------

Next control is "cboCountry" with similar NotInList event.


I am thinking to add a field "Country" in tbl "MainCity" and get its value as

=[cboResidenceCity].Column(1) and make control as text field instead of combobox.


My main question is if i do so, when "cboResidenceCity" NotInList event triggers how 

will the field "Country" be filled when it is a new "MainCity" ?


Please help.

Regards,

Khalid



__._,_.___

Posted by: khalidtanweerburrah@yahoo.com
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (1)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar