PDA

View Full Version : Feelin like a newb



akn112
01-25-2007, 12:20 PM
Hey again, here's another question

Say i have two tables. how would i make it so that when i click a button, it will take the first entry of the list and compare it against all other entries of the other list. If the program finds one entry that is equal, it goes to the next entry in the first list. If it doesnt find one it saves the entry(in another table called difference) and goes to the next entry. It continues to do this for the rest of the list. Right now i have


Private Sub Toggle7_Click()
Dim strsql As String
Record1:
If Me![DS].Form![Name] = Me![export_psdb].Form![Station] Then
GoTo NextRecord
Else
DoCmd.GoToControl "export_psdb"
DoCmd.GoToRecord
If Me![export_psdb].Form![Station] <> Null Then
GoTo Record1
Else
GoTo CreateDifference:
End If
End If
Exit_now:
Exit Sub
NextRecord:
DoCmd.GoToControl "DS"
DoCmd.GoToRecord
If Me![DS].Form![Name] = Null Then
GoTo Exit_now
End If
GoTo Record1
CreateDifference:
strsql = "UPDATE [Difference] SET [Difference].[Station Name] = forms![DS]!Name "
DoCmd.GoToControl "Differences"
DoCmd.GoToRecord
GoTo NextRecord
End Sub

OBP
01-26-2007, 04:50 AM
Do you really need to do this with VBA?
Are you doing it in VBA as a learning experience?
If it is not essential to do this in VBA have a look on the Queries Tab Main Menu
New>Find Unmatched Query Wizard.
It will create a query for you that will list all Unmatched entries in one table when compared to another table.
You can then use that query to create an Append query to add those records to your "Difference" Table.

akn112
01-29-2007, 11:58 AM
guess that works! thanks!