Thanks Jeff
I want to add a new record in Fields [med1],[med2], ...[med7] of MemoR
table
with values from field [medlat] of table RpInstant so that first value
is
in
[med1] , second value is in [med2] and so on ; here is the whole code I
tried
:
Private Sub Command36_Click()
Dim dbs As DAO.Database
Dim rstInstant As DAO.Recordset
Dim rstMemoR As DAO.Recordset
Dim strmed As String
Dim varInst As Variant
Dim instROW As Integer
Dim instCOL As Integer
Dim IntX As Integer
Dim IntA As Integer
Set dbs = CurrentDb
Set rstInstant = dbs.OpenRecordset("SELECT RpInstant.NrCrtMED,
RpInstant.NrCrtMR, RpInstant.NewNR, RpInstant.medlat, RpInstant.medfab,
RpInstant.doza, RpInstant.cant, RpInstant.proc, RpInstant.lista,
RpInstant.tipdg, RpInstant.cod FROM RpInstant ORDER BY
RpInstant.lista",
dbOpenSnapshot)
Set rstMemoR = dbs.OpenRecordset("MemoRetete")
strmed = "med" & IntA + 1
IntX = rstInstant.RecordCount
varInst = rstInstant.GetRows(IntX)
instROW = UBound(varInst, 2) + 1
instCOL = UBound(varInst, 2) + 1
For IntA = 1 To IntX
With rstMemoR
.AddNew
![Eval(strmed)] = varInst(3, IntA)
.Update
End With
Next IntA
Set dbs = Nothing
Set rstInstant = Nothing
Set rstMemoR = Nothing
End Sub
(I have an application in Access 2007)
Your suggestions are very appreciated ;
:
It appears you are trying to use fieldnames that look like "med1",
"med2",
....
If so, you have ... a spreadsheet! Repeating fieldnames (like the
above)
are a strong indicator that your table structure would benefit from
further
normalization. You won't get the best use of Access'
relationally-oriented
features/functions if you feed it 'sheet data.
Or have I read too much into a small snippet of code? If so, provide
a
more
detailed description for more detailed suggestions...
--
Regards
Jeff Boyce
www.InformationFutures.net
Microsoft Office/Access MVP
Microsoft IT Academy Program Mentor
http://microsoftitacademy.com/
message
I want to refer to a recordset field like this :
For IntA = 1 To IntX
With rstMemoR
.AddNew
![Eval(strmed)] = varInst(3, IntA) ' strmed =
"med"&IntA
.Update
End With
Next IntA
Everything seems to be OK except the ![Eval(strmed)] part .
If somebody can help it would be very appreciated