Need help with VBA syntax

Montez659

Well-known Member
Joined
May 4, 2005
Messages
918
Such an easy problem I think, but I can't get it. I have this in my VBA for the form_current:
Code:
Dim varArchive1

If IsNull("Me.Assigned To.Value") Then
    varArchive1 = 0
Else
    varArchive1 = DLookup("[archive]", "Contacts", "[ID]= " & [Forms]![Task Details]![Assigned To])
End If

If varArchive1 = -1 Then
    [Forms]![Task Details]![Assigned To].RowSourceType = "Table/Query"
    [Forms]![Task Details]![Assigned To].RowSource = "qryAllContacts"
Else
    [Forms]![Task Details]![Assigned To].RowSourceType = "Table/Query"
    [Forms]![Task Details]![Assigned To].RowSource = "qryLimitedContacts"
End If
End Sub
Not sure if my syntax is correct here:
Code:
If IsNull("Me.Assigned To.Value") Then
Wish I could change that space but I can't.
The problem that I am getting is that when the form loads up to insert a new record, it doesn't recognize that "assigned to" is blank, and so triggers an error when it tries to do the dlookup.
I even tried an on error goto to run the code to set the rowSourceType and RowSource, but it seems to ignore this altogether.
Last note: Everything worked fine before I split the db. Now that it is split, I am coming up with the error on the dlookup. Any ideas?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Interesting...The old addage about Access not liking spaces will always continue to hold true. It seems that when the split occured, Access treated the space as an underscore which through all my code off. All seems to be working well now.
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,348
Members
452,907
Latest member
Roland Deschain

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top