Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help updating or adding data to a record using VBA

Status
Not open for further replies.

Poobear1929

Technical User
May 11, 2004
32
US
I need some help, I would like to either write a SQL statment in module or run two queries I built. I think the SQL statment is the way to go though, but don't have much expeirence with it. Here is my problem, I want to add a record to a table if a certain condition doesn't exist. For example

Form = HMAL Meaning
Field 1 = MCN_Key
Field 2 = HMAL
Table = Raptor
Primary key = MCN
The other field I want updated = HMAL

If Form!HMAL Meaning!MCN_key = Raptor!MCN then don't create a new record, next update the Raptor!HMAL to equal FORM!HMAL Meaning!HMAL where Form!HMAL Meaning!MCN_key = Raptor!MCN
If there isn't a record in the Raptor table where Raptor!MCN equals the Form!HMAL!MCN_key, then create one and update the Raptor!HMAL to equal the HMAL Meaning!HMAL.

I hope this makes sense. It would sure help me out a lot if some one how I could write this.

Thanks

Poobear


 
Take a look at the DLookUp function and at the DoCmd.RunSQL method.
You may also consider playing with Recordset.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top