recordsource does not exist (1 Viewer)

bobbybeers

Registered User.
Local time
Today, 09:00
Joined
Mar 14, 2013
Messages
17
I am assigning a recordset using vbs code. The variable "CB_proj" is a combobox value. The problem comes when the combobox is null, the program errors out and even if I try to exit the routine with an if statement, it still compiles the line of code and errors out because the object doesn't exist. Any ideas how I can get it to not compile that error if my combox value is null?? Thanks to anyone who could help with ideas

CB_proj = Forms!CC_MAIN.CB_proj

strSQL = "SELECT " & [CB_proj] & ".* FROM " & [CB_proj] & ";"
Forms!CC_MAIN.projdat.Form.RecordSource = strSQL
Forms!CC_MAIN.projdat.Form.Requery
Forms!CC_MAIN.Form.Requery
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:00
Joined
Aug 30, 2003
Messages
36,126
Wrap the whole bit in an If/Then block that tests it and only continues if it has a value.
 

bobbybeers

Registered User.
Local time
Today, 09:00
Joined
Mar 14, 2013
Messages
17
Thanks!! :)
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 08:00
Joined
Aug 30, 2003
Messages
36,126
No problem, and welcome to the site by the way!
 

Users who are viewing this thread

Top Bottom