In my data base I have my normal data table and an archive data table. On a form I have an archive button. When the archive button is clicked I want to check to see if the data I am about to Archive has already been archived. So, I have a simple query that looks at three fields in both tabls...It has a calculation that produces a 1 if the data is already in the second table. The query is linked to the form where the Archive button was clicked. That form shows the three fieds with specific informaiton. So the query will return...
Form 1 2 2, query based on form...Main table...1 2 3. Archive Table 1 2 3..calculation equals 1. Dup. It would return 0 if the Archive table did not have the information that the Form/Main Table had selected to look at. This all works.
Problem: In VB I want to store the results of the query in a variable. I can then check to see if the results were a 1 ot 0. If it is a 1 I would send a message to the user that the data had already been archived and stop any further action.
Here is what I have done in VB attached to the Archive button:
Dim Duplicate
Duplicate = queryname (no brackets or quotes..no spaces in query name.
MsgBox Duplicate
(more code to come later)
The code runs but the message box shows nothing. I can't be sure Duplicate variable has been set to anything.
Two questions:
1. How can I make what I outlined work?
2. Is there a better way to do this whole thing.
Form 1 2 2, query based on form...Main table...1 2 3. Archive Table 1 2 3..calculation equals 1. Dup. It would return 0 if the Archive table did not have the information that the Form/Main Table had selected to look at. This all works.
Problem: In VB I want to store the results of the query in a variable. I can then check to see if the results were a 1 ot 0. If it is a 1 I would send a message to the user that the data had already been archived and stop any further action.
Here is what I have done in VB attached to the Archive button:
Dim Duplicate
Duplicate = queryname (no brackets or quotes..no spaces in query name.
MsgBox Duplicate
(more code to come later)
The code runs but the message box shows nothing. I can't be sure Duplicate variable has been set to anything.
Two questions:
1. How can I make what I outlined work?
2. Is there a better way to do this whole thing.