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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

update table

Status
Not open for further replies.

gray78

Programmer
Feb 3, 2005
78
US
I have two tables, Scantable1 and serial#. In a form, I am pulling a field from scantable1(tagno). I am inputting information into this form and want to be able to update the serial# table with the for data. I need to know how I can update the serial# table with the tagno field from the scantable1 table if it does not exist in the serial# table.

Thanks
 
hi gray78...
first of all, it is advisable to name your tables consistently, like tblScan and tblSerial#.

You cant update your tblSerial with the TagNo-field if the TagNo-field is not in that table. Maybe add this field to tblSerial and create a link between the tables? And go from there...



Pampers.

You're never too young to learn
 
How are ya gray78 . . . . .

Hard to say yet . . . . what is your [blue]table structure[/blue] & [blue]relationships[/blue]?

Calvin.gif
See Ya! . . . . . .
 
The tagno field is in both tables and is the primary key.
The input data being written into the form is being saved into the serial# table but I want to also save the tagno data being pulled from the scantable1 to be put into the serial# table if it is not there with associated data.
 
gray78 . . . . .

Not quite what I was looking for, but you can use the DLookup function to determine wether to transfer tagno. Something like this:
Code:
[blue]   Dim Criteria As String
   
   Criteria = "[TagNo] = [red][b]'[/b][/red]" & Me!TagNo & "[red][b]'[/b][/red]"
   
   If IsNull(DLookup("[TagNo]", "Serial#", Criteria)) Then
      [green]'Transfer TagNo[/green]
   Else
      [green]'What to do if TagNo exist[/green]
   End If[/blue]
If tagno is numeric, remove singe quotes on the criteria line . . .

Calvin.gif
See Ya! . . . . . .
 
tagno is a text field, however, still not able to get the tagno from scantable1 table to insert into serial# table.

any suggestions??
 
gray78 . . . .

and this:
Code:
[blue]   Dim Criteria As String, SQL as String
   
   Criteria = "[TagNo] = '" & Me!TagNo & "'"
   
   If IsNull(DLookup("[TagNo]", "Serial#", Criteria)) Then
      [purple][b]SQL = "Your Append SQL"
      Docmd.RunSQL SQL[/b][/purple]
   Else
      'What to do if TagNo exist
   End If[/blue]

Calvin.gif
See Ya! . . . . . .
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top