473,408 Members | 1,809 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Trouble with updating tables/ maybe a requery is needed- but how?

I have a form with 2 command buttons on it. One button executes some append
queries. The other button creates a report from a query which reads data in
part created by the first button. But when I do the buttons in succession,
I don't get any data in my report. If I close the form then go back into
and position it at the same record, the report works. I don't understand
this because I'm opening the report and the query attached to it after
finishing the table update. Does anybody know how I can correct this and
make my report work without closing and reopening my form?

Robert

here is the code for the update button:

On Error GoTo Err_Command27_Click

Dim stDocName As String
Dim strmsg As String

stDocName = "qryStartRental"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName, acNormal, acEdit

stDocName = "qryItemOutRental"
DoCmd.OpenQuery stDocName, acNormal, acEdit

cmbItemNo.Requery
DoCmd.SetWarnings True

strmsg = "Rental has been booked for customer "
strmsg = strmsg & [Forms]![frmrentals]![fldCustNo]
strmsg = strmsg & " item " & [Forms]![frmrentals]![flditemno]
MsgBox strmsg

Exit_Command27_Click:
Exit Sub

Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click


Here is the code for the report button:

On Error GoTo Err_Command33_Click

Dim stDocName As String
Dim stCond As String
Dim icount As Integer

icount = 0
icount = DCount("[fldrentalstartdate]", "tblRentalStarts",
"[fldrentalno] = [forms]![frmrentals]![fldrentalno]")
If icount > 0 Then
stDocName = "rptContract"
DoCmd.OpenReport stDocName, acPreview, , "qrycontract2.fldrentalno =
[forms]![frmrentals]![fldrentalno]"
Else
MsgBox "Booking not found. Have you booked the rental yet?"
End If

Exit_Command33_Click:
Exit Sub

Err_Command33_Click:
MsgBox Err.Description
Resume Exit_Command33_Click
Nov 13 '05 #1
3 1142
I figured it out. (I used docmd.gotorecord). Thanks.
"Robert" <pr**********@yahoo.com> wrote in message
news:TE*****************@fe02.lga...
I have a form with 2 command buttons on it. One button executes some
append queries. The other button creates a report from a query which reads
data in part created by the first button. But when I do the buttons in
succession, I don't get any data in my report. If I close the form then go
back into and position it at the same record, the report works. I don't
understand this because I'm opening the report and the query attached to it
after finishing the table update. Does anybody know how I can correct this
and make my report work without closing and reopening my form?

Robert

here is the code for the update button:

On Error GoTo Err_Command27_Click

Dim stDocName As String
Dim strmsg As String

stDocName = "qryStartRental"
DoCmd.SetWarnings False
DoCmd.OpenQuery stDocName, acNormal, acEdit

stDocName = "qryItemOutRental"
DoCmd.OpenQuery stDocName, acNormal, acEdit

cmbItemNo.Requery
DoCmd.SetWarnings True

strmsg = "Rental has been booked for customer "
strmsg = strmsg & [Forms]![frmrentals]![fldCustNo]
strmsg = strmsg & " item " & [Forms]![frmrentals]![flditemno]
MsgBox strmsg

Exit_Command27_Click:
Exit Sub

Err_Command27_Click:
MsgBox Err.Description
Resume Exit_Command27_Click


Here is the code for the report button:

On Error GoTo Err_Command33_Click

Dim stDocName As String
Dim stCond As String
Dim icount As Integer

icount = 0
icount = DCount("[fldrentalstartdate]", "tblRentalStarts",
"[fldrentalno] = [forms]![frmrentals]![fldrentalno]")
If icount > 0 Then
stDocName = "rptContract"
DoCmd.OpenReport stDocName, acPreview, , "qrycontract2.fldrentalno
= [forms]![frmrentals]![fldrentalno]"
Else
MsgBox "Booking not found. Have you booked the rental yet?"
End If

Exit_Command33_Click:
Exit Sub

Err_Command33_Click:
MsgBox Err.Description
Resume Exit_Command33_Click

Nov 13 '05 #2
Likely, the problem here is that data have been entered in the form..but not
yet saved to disk.

Just force a disk write. You can use

me.Refresh

Make the above the first line of your code....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal
Nov 13 '05 #3
I just discovered that. And gotorecord needs a numbering. Thanks for your
help, Albert. It's working.
"Albert D. Kallal" <ka****@msn.com> wrote in message
news:n1Vde.1211900$Xk.506672@pd7tw3no...
Likely, the problem here is that data have been entered in the form..but
not yet saved to disk.

Just force a disk write. You can use

me.Refresh

Make the above the first line of your code....

--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.members.shaw.ca/AlbertKallal

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Andreas Lauffer | last post by:
I changed from Access97 to AccessXP and I have immense performance problems. Details: - Access XP MDB with Jet 4.0 ( no ADP-Project ) - Linked Tables to SQL-Server 2000 over ODBC I used...
1
by: Gerry Abbott | last post by:
Hi all, I've got two subforms on an unbound form, frmMain, frmSubOne, frmSubTwo. Ive got a control on frmSubTwo, cboList, a list box, which draws its source from the table underlying frmSubOne....
5
by: chris vettese | last post by:
I have a table called table1 that has a one to many relationship to table2. What I would like to do is have a form with two list boxes on it. The first list box will have a field from all of the...
2
by: Basic | last post by:
Why doesn't this code work: -------------------------code snippet----------------- Dim categorysource As String categorysource = "SELECT ., ., ." & _ " FROM KSTUDY_KSTUDY " & _ " WHERE . = "...
0
by: cwbp17 | last post by:
I'm having trouble updating individual datagrid cells. Have two tables car_master (columns include Car_ID, YEAR,VEHICLE) and car_detail (columns include Car_ID,PRICE,MILEAGE,and BODY);both tables...
16
by: scorpion53061 | last post by:
Well as some of you know I was using a tab control for a project I was building for my boss. Today he tells me that he wants: When he switches tabs to be able to switch back and see whatever...
4
by: Macbane | last post by:
Hi, I have a 'main' form called frmIssues which has a subform control (named linkIssuesDrug) containing the subform sfrmLink_Issues_Drugs. A control button on the main form opens a pop-up form...
4
by: aaronyoung | last post by:
I have created custom navigation buttons and Record Number indicators on several forms that are used to review and update records based on a query. My On Current event to update the "Record X of...
9
by: Steve67 | last post by:
Need a little assistance with a VBA code for updating tables through a form. I have a form with two text boxes and a command button. One text box is named txtNewPartNumber and the other text box is...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.