Refreshing Form Information

  • Thread starter Thread starter Bill Phillips
  • Start date Start date
B

Bill Phillips

I have a form based on a table. I need to edit a value in
the form insert into a different table then delete the
record. I can do all of this using the following code, but
after the code runs the fields of the form show #Deleted.
I have tried a variety of ways to requery the form, but I
keep getting errors.

Private Sub cmdAddRecord_Click()

Dim rs As New ADODB.Recordset
Dim oconn As ADODB.Connection
Dim dbstemp As Database
Set dbstemp = CurrentDb

Dim ItemLoc As String
Dim ItemID As String
Dim ItemQty As Long
Dim ItemScanDate As Date
Dim ItemScanTime As Date
Dim ItemUser As String

Dim strSql As String
Dim strSqlDel As String

ItemLoc = Me.txtNewLoc
ItemID = Me.Item
ItemQty = Me.Qty
ItemScanDate = Me.ScanDate
ItemScanTime = Me.ScanTime
ItemUser = Me.User



strSql = "INSERT into tblInvScanIn (Item, Loc, Qty,
ScanDate, ScanTime, User) values ('" & ItemID & "', '" &
ItemLoc & "', '" & ItemQty & "', '" & ItemScanDate
& "', '" & ItemScanTime & "', '" & ItemUser & "')"
dbstemp.Execute strSql

MsgBox "Record Added"

DoCmd.OpenQuery "qryNeedValidLocDel", acViewNormal,
acEdit

frmNeedValidLoc.Requery

DoCmd.GoToControl "txtNewLoc"

Me.txtNewLoc.Value = Null


End Sub


Any help is most appreciated.
 
If the code is on the same form, simply use:
Me.Requery

If the code is running on a different form, use:
Forms!frmNeedValidLoc.Requery

Good luck.

Sco
 
Back
Top