Intersection between fields and records in table

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, how can i make the vba update x value where fields and records intersect to given x critiries in a table?

When i click button on the form i want following condition to run into table1 and update records
If field "Names" = form1.combobox1.value and
if field "Dates" = form1.combobox2.value?
update form1.textbox1.value where names and dates value intersect.

Thanks for helping
Pedie
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
You would use a UPDATE query:
Code:
Dim s As String
s = ""
s = s & " UPDATE Table1 SET "
s = s & " Field1 = '" & Me.txtName.Value & "',"
s = s & " Field2 = " & "#" & Me.txtDate.Value & "#"
s = s & ";"

On Error Resume Next
CurrentDb.Execute s, dbFailOnError
If Err Then
    Msgbox "Error updating table!"
Else
    Msgbox "Table Updated!"
End If

Note that we are careful when creating SQL statements to put text values in single quotes and dates in hashes (this is peculiar to Access - most DB's use single quotes for dates too).

Now Pedie, this is a basic SQL query ... I hope you working on learning your SQL... :rolleyes:

The main thing about SQL is its set-oriented and not row/column oriented. It won't look for an intersection in a physical sense but in the mathematical sense of set operations - the set of all records in Table1 having this name in Field1 and this date in Field2. So this might be 0, 1, or many records that are updated as a result of this query.
 
Upvote 0
Xen, thanks alot for helping out!
Apologies got late reply and 'll have to try this out tomorrow and get back again....thanks again and have a great! weekends!
 
Upvote 0

Forum statistics

Threads
1,224,527
Messages
6,179,345
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