Open forms based on matching parameters

Joined
Aug 21, 2006
Messages
1
Reaction score
0
Open forms using stLinkCriteria

Hi all,

I am a bit of a newbie to VBA and this is also my first online post to a forum, ever. So please be kind!

I have set up a custom form using a combo box to choose parameters. If there is a match in the related table I want it to open the form fvRiskA. If there is no match I would like it to display either a message box informing the user that there are no matches or another custom form that will display some text stating that their are no matches (fMsgNoCategory).

Here is the current variation of the code I have now:

Private Sub bSearchCategory_Click()
On Error GoTo Err_bSearchCategory_Click

Dim stDocName As String
Dim stLinkCriteria As String

stLinkCriteria = "[aCg]=" & "'" & Me![CatCrit] & "'"

If stLinkCriteria = stLinkCriteria Then
stDocName = "fvRiskA"
Else
stDocName = "fMsgNoCategory"
End If

DoCmd.Close
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_bSearchCategory_Click:
Exit Sub

Err_bSearchCategory_Click:
MsgBox Err.Description
Resume Exit_bSearchCategory_Click

End Sub

I have looked at some similar posts on this and other forums but have not been able to find anything that relates to this specific situation. Any help would be greatly appreciated.

Thanking you in advance

Sopdet
 
Last edited:

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top