Selasa, 28 Maret 2017

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

 

Kumar-


If you're inserting a record in code, you have to Requery any open forms showing data from that table.  They won't show up without that or closing and reopening.

John Viescas, Author
Effective SQL
SQL Queries for Mere Mortals 
Microsoft Access 2010 Inside Out
Microsoft Access 2007 Inside Out
Microsoft Access 2003 Inside Out
Building Microsoft Access Applications 
(Paris, France)




On Mar 28, 2017, at 7:55 PM, access_kri@yahoo.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com> wrote:



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: John Viescas <johnv@msn.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (2)

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