Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

not finding form in VB code

Status
Not open for further replies.

jedder18

Technical User
Mar 4, 2013
29
0
0
US
Using Access 2007
Windows 7

Using this code to find duplicate client ID and have message popup.
Keep getting error on If clientidTemp line saying cannot find the client info form...
That's the name of the form. Is it because of space in title or the form does have 3 tabbed pages on it.
Do I need to look for the page on the form?
Please help...


Private Sub IDClient_AfterUpdate()
Dim clientidTemp As Variant
clientidTemp = DLookup("[ClientID]", "Client Table", "[ClientID]= Forms![Client Info]![IDClient]")
[highlight #FCE94F]If clientidTemp = Forms!Client Info!IDClient Then[/highlight]
Me!IDClient.SetFocus
Me.Undo
MsgBox "DUPLICATE CLIENT ID. Please re-enter.", vbOKOnly, "Duplicate CLIENT ID"
End If
End Sub

TIA..

Jennifer

Jedder

 
Use this syntax:
Forms![Client Info]!IDClient

But, I think its safer to test like this:
If Not IsNull(clientidTemp) Then

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
I put the brackets in right after I posted the question.
Works like a charm...
Thanks much.

Jedder

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top