Selasa, 28 Maret 2017

[MS_AccessPros] Command button greyed if no entry in related form/table

 

Dear Group,

              I have a main continuous form called "F_EquipSpecs" which has command button "History" to open a related form "F_History" showing a specific record based on the selection of in the main continuous form. I enter new record in the main form and through command button run append query to populate the foreign key (EquipmentID) in the related table "T_History". Other fields such as "Activity Description"  in the related table "T_History" are blank at this stage.


              What  I want to achieve is that when I open the main form (F_EquipSpecs" and a particular record is selected and if the related table field  say "activity" is blank, the command button should be greyed and on click should display message box "there is no data" and if there is data, the command button should be normal on open the F_History form specific to that equipmentID


              I tried the following but is not working. Please help.

-----------------------------------

Private Sub cmdHistory_click ()

Dim stLinkCriteria As String

    stDocName = "F_History"
    stLinkCriteria = "[lookupEquipment]=" & "'" & Me![EquipmentID] & "'"
    If IsNull([Forms]![F_History]![Activity]) = True Then
    MsgBox "Sorry No History exists for the equipment", , "No Details"
    DoCmd.OpenForm stDocName, , , stLinkCriteria
    Exit Sub
    End If
   
    If IsNull(Forms]![F_History]![Activity]) = False Then
   
    DoCmd.OpenForm stDocName, , , stLinkCriteria
   
    End If
   
End Sub

----------------------------------

Regards,

kumar  

__._,_.___

Posted by: access_kri@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