dbTalk Databases Forums  

Form changes value in table

comp.databases.ms-access comp.databases.ms-access


Discuss Form changes value in table in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bob B.
 
Posts: n/a

Default Form changes value in table - 02-28-2011 , 03:05 PM






I have a problem that is plaguing me at the moment.

I have a simple form which contains one combo box that selects a value
for the "PooledID" field from a query and a textbox that give the
value of the PooledID.

This works OK the first time I use it for a given PooledID. But,
after I close this form with a Cancel command button, it puts in the
value of PooledID into the last record in the table. Why? I have
commented out the VBA code and it still does the same thing when I
close the form.The problem is associated with the form, its controls
and closing it. (The next time I select that same PooledID, it finds
one record with the DCount() command.

The Record Source for the form is

SELECT Samples.*, Samples.AssayID, Samples.SampleNumber FROM Samples
ORDERBY Samples.AssayID DESC , Samples.SampleNumber DESC;

The query for the cbo box is

SELECT qryTotalPooledData.PooledID, [PooledName] & ", " & [Category]
& ", " & [ZoneName] AS List, qryTotalPooledData.PooledName,
qryTotalPooledData.Category,
qryTotalPooledData.ZoneName,
qryTotalPooledData.PooledAccountableAreaFROM qryTotalPooledDataORDER
BY qryTotalPooledData.ZoneName, qryTotalPooledData.Category,
qryTotalPooledData.PooledName;

The VBA code for the command "Get Group results" is

Dim strMsg As String
Dim intNoRecords As Variant
Dim intPooledID As Integer
Dim intResponse As Integer
Dim SQL As String

' Get the value for the PooledID
intPooledID = Me.txtPooledID.Value
' Be sure there are records in the "Samples" table with that value for
the Pooled ID
intNoRecords = DCount("[ID]", "Samples", "[PooledID] =" & intPooledID)

" If there are none give a message then exit
If intNoRecords = 0 Then
intResponse = MsgBox("The Group with ID number " & intPooledID & _
" has no Samples associated with it!", _
vbOKOnly)

Exit Sub

End If

' If there are records, then do the analysis and print the results
DoCmd.OpenReport "rptGroupBioburdenCalculationPlusONEAssay",
acViewPreview

End Sub


Anybody have any idea why this changes the value of PooledID in the
record? Is it a glitch in Access2007? More likely I am doing something
stupid. I have only been at this for a year or so.

Bob B.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.