Let me please introduce a bit of context first: Building up from Gonzalo Medina's answer to Include chapters in List of Figures with titletoc?, I added the same features to a List of Tables. While everything went fine with my List of Figures, the List of Tables got the chapter line (for each new chapter where a table occurs) saved to the \jobname.lot file after the line corresponding to the first table.
There is something related with the contents of the chapters in my document that leads to this weird result, as I've tried with exactly the same class and packages but with MWE-like chapters and everything went fine about the tables, too. This is the reason why I'm not asking here about the occurrence of this strange feature --it may be something lurking in my own chapter files, although I haven't been able to disclose what it may be and what I've been checking results in really weird stuff. Nonetheless, if somebody has seen the same feature occurring, any suggestions about its origin will be welcome.
I'm trying with a different approach: My class is based on memoir and I'm using a new file extension (lotb) to store the data about the chapters and the tables in the file \jobname.lotb using the same approach as put forward by Gonzalo Medina (except for a few minor changes based on memoir). Everything runs smoothly with this approach, but I don't know how I'm supposed to retrieve the page numbers for the tables in order to take them to the \jobname.lotb file.
What follows is an MWE, my true setting being much more complex than this.
Also, any suggestions on how to improve my approach overall would be very welcome.
\documentclass{memoir}
\usepackage{etoolbox}
\makeatletter
\def\thischaptertitle{}
\def\thischapternumber{}
\def\thistabtitle{}
\newtoggle{noFigs}
\newtoggle{noTabs}
%<- My new "list of"
\def\listoftabsname{Tables}
\newlistof{listoftabs}{lotb}{\listoftabsname}
\def\tabsmark{\listoftabsname}
\AtBeginDocument{%
% I part ways slightly from Gonzalo Medina's answer by resorting
% to a memoir-based hook
\apptocmd{\memendofchapterhook}{%
\gdef\thischaptertitle{\f@rtoc}%
\gdef\thischapternumber{\thechapter}%
\global\toggletrue{noTabs}%
\global\toggletrue{noFigs}%
}{}{}
% This is going to be used to get the content of the caption of a table.
% But, how do I get the page number?
% Plus, I guess it can be done much better than this
\apptocmd{\@caption}{%
\gdef\thistabtitle{\@currentlabelname}%
\gdef\thistabpage{}%<- How to?
}{}{}
% In my true setting I have to do this AtEnd, instead of AtBeginning
\AtEndEnvironment{table}{%
\iftoggle{noTabs}{
\global\togglefalse{noTabs}
\addtocontents{lotb}{%
\protect\contentsline {chapter}%
{\protect\numberline {\thischapternumber}{\protect\ignorespaces\thischaptertitle}}{}{}
\protect\vskip0.125\protect\baselineskip}%\addvspace{5\p@}}}
}{}
}
% This goes AtEndEnvironment{table} in order to have the right counter value;
% otherwise, it is lagging one unit behind; e.g., the first is \thechapter.0
\AtEndEnvironment{table}{%
\addtocontents{lotb}{%
\protect\contentsline {table}%
{\protect\numberline {\thetable}{\protect\ignorespaces\thistabtitle}}{\thistabpage}{}
\protect\vskip0.125\protect\baselineskip}%\addvspace{5\p@}}}
}%
% Everything runs smoothly for the figures
\AtBeginEnvironment{figure}{%
\iftoggle{noFigs}{
\addtocontents{lof}{\protect\contentsline {chapter}%
{\protect\numberline {\thischapternumber}{\protect\ignorespaces \thischaptertitle}}{}{}
\protect\vskip0.125\protect\baselineskip}%\addvspace{5\p@}}
\global\togglefalse{noFigs}
}{}
}%
}
\makeatother
% I'm using all of the packages below (and more) in my original setting.
% They appear here just because I think they can be relevant in order to provide a context
% for any possible answers to work in my real-life scenario
\usepackage[figurewithin=chapter,tablewithin=chapter]{caption}
\usepackage{titletoc}
\usepackage[toctitles,explicit]{titlesec}
\usepackage{hyperref}
\usepackage{cleveref}
\begin{document}
\tableofcontents
\listoffigures*
\listoftabs
\chapter{One}
\begin{figure}
One
\caption{One.}
\end{figure}
\begin{table}
\caption{One.}
One
\end{table}
\begin{table}
\caption{Oneb.}
Oneb
\end{table}
\chapter{Two}
\begin{figure}
Two
\caption{Two.}
\end{figure}
\begin{table}
Two
\caption{Two.}
\end{table}
\chapter{Three}
\begin{figure}
Three
\caption{Three.}
\end{figure}
\begin{table}
Threeb
\caption{Threeb.}
\end{table}
\end{document}
EDIT: My original problem, which brought all of the above on stage, has been solved with the approach I explain in my non-answer post below.

\gdef\thistabpage{\thepage}works for me, but your approach does not allow for hyperlinks – Aug 28 '16 at 04:04