
Form displays recordset depending of a value
Quote:
> As a student i'm designing a database of recipes
> Having design a form which displays the list of recipes, an input box offers the
> possibility of accessing a recipe by entering the recip's ID number then clicking
> a command button.
> Not familiar with VB , i'm lost.
> If anyone as any suggestions they will be welcome, here is how i started.
> ThanksPrivate Sub Display_Click()
> Dim db As database
> Dim rs As Recordset
> Dim number As Integer
> Set db = CurrentDb("db1")
> Set rs = db.Openrecord("Recipe by ID number", dbOpenTable)
> Set number = Forms![Recipe List Form]![IDtextbox.value]
> If Forms![Recipe by ID number]![RecipeID.value] = number Then
> DoCmd.OpenForm Forms![Recipe by ID number]
> Else: number = ""
> DoCmd.OpenForm = Forms![No Value frm]
> End If
> End Sub
There are a lot of syntactical errors in your code, if I understand the logic, you
want to check that a record with the required recipeID exists, if it does, open up a
form with the selected record, otherwise, open up a different form, if so try the
following, otherwise let me know.
Private Sub Display_Click()
Dim intNum As Integer
intNum = Me!IDtextbox.value
If IsNull(DLookup("RecipeID", "Recipe by ID Number", "RecipeID = " & intNum))
Then
DoCmd.OpenForm "No Value frm"
Else
DoCmd.OpenForm "Recipe by ID number", , , "RecipeID = " & intNum
End If
End Sub
Let me know if this works. Hope this helps
Tony Oakley