MS ACCESS VBA If Form textbox value in table and date is not null then

deer777
deer777 used Ask the Experts™
on
Need to write VBA to determine if a textbox value is in table then . . . update table
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
then I need to run stored procedure to insert into table on the SQL Server side
Most Valuable Expert 2012
Top Expert 2014
Commented:
You'll have to give a little more detail.

Do you want to determine if the value exists in a specific column in the table? Or in several columns in the table?

You can use DCount to determine if it exists in a single column:

If Nz(Dcount("*", "YourTable", "YourColumn=" & Me.YourTextbox), "") <> "" Then
  '/ the value exists
Else
  '/ the value does not exist

You'd have to show us the stored proc in order for us to provide you with specific advice on running that.
End If
Distinguished Expert 2017

Commented:
VBA doesn't directly access tables.  You would do this by creating an update query that selects the record you want to update if the value is null and sets the value to whatever you want.

I'm guessing that you are making this harder than it needs to be.  Are you not using a bound form?

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial